vitessio/vitess · error

error connecting to %s using %v protocol: %v

Error message

error connecting to %s using %v protocol: %v

What it means

After a connection of the selected protocol is created, createConns wraps any connect failure with this message identifying the host, protocol and underlying cause. The root problem is in the wrapped error (DNS, refused, TLS, auth), not in this message itself.

Source

Thrown at go/vtbench/vtbench.go:167

		switch b.ConnParams.Protocol {
		case MySQL:
			log.V(5).Info(fmt.Sprintf("connecting to %s using mysql protocol...", host))
			conn = &mysqlClientConn{}
			err = conn.connect(ctx, cp)
		case GRPCVtgate:
			log.V(5).Info(fmt.Sprintf("connecting to %s using grpc vtgate protocol...", host))
			conn = &grpcVtgateConn{}
			err = conn.connect(ctx, cp)
		case GRPCVttablet:
			log.V(5).Info(fmt.Sprintf("connecting to %s using grpc vttablet protocol...", host))
			conn = &grpcVttabletConn{}
			err = conn.connect(ctx, cp)
		default:
			return fmt.Errorf("unimplemented connection protocol %s", b.ConnParams.Protocol.String())
		}

		if err != nil {
			return fmt.Errorf("error connecting to %s using %v protocol: %v", host, cp.Protocol.String(), err)
		}

		// XXX handle normalization and per-thread query templating
		query, bindVars := b.getQuery(i)
		b.threads = append(b.threads, benchThread{
			b:        b,
			i:        i,
			conn:     conn,
			query:    query,
			bindVars: bindVars,
		})

		if time.Now().After(report) {
			fmt.Printf("Created %d/%d connections after %v\n", i, b.Threads, time.Since(start))
			report = time.Now().Add(reportInterval)
		}
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Read the wrapped cause and fix it (connection refused → tablet down/port wrong; auth → fix credentials)
  2. Verify the host:port with `mysql -h <host> -P <port>` or `vtctldclient GetTablets`
  3. Check network/firewall/TLS settings between the bench runner and tablets

Example fix

// before
// error connecting to tablet-0 using mysql protocol: dial tcp 10.0.0.5:3306: connect: connection refused
// after
// start the tablet or correct the port
vtbenchclient.Run(ctx, "--port", "15000", ...)
Defensive patterns

Strategy: retry

Validate before calling

conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, port), 3*time.Second)
if err != nil { return fmt.Errorf("host unreachable before bench: %v", err) }
conn.Close()

Try / catch

if err := b.Run(ctx); err != nil {
    var nerr net.Error
    if errors.As(err, &nerr) || strings.Contains(err.Error(), "error connecting to") {
        // backoff and retry; surface wrapped cause
        return fmt.Errorf("bench target down: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling vtbench.Run / createConns when conn.connect(ctx, cp) returns an error for a host — unreachable tablet, wrong port, TLS mismatch, auth failure.

Common situations: Benchmarking against a tablet that is down or behind a firewall; wrong --port; MySQL credentials rejected; certificate/hostname mismatch with secure transport.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/86bb2a33e59032bb. Report an issue: GitHub.