googleapis/mcp-toolbox · critical

unable to create connection pool: %w

Error message

unable to create connection pool: %w

What it means

The YugabyteDB source failed to construct its pgx connection pool. initYugabyteDBConnectionPool assembles a pgx connection string from config (host, port, user, pass, load balance, topology keys, etc.) and calls pgxpool.New; any failure there — bad DSN, DNS resolution failure, unreachable node, auth rejection — is wrapped with this message.

Source

Thrown at internal/sources/yugabytedb/yugabytedb.go:160

	i := fmt.Sprintf("postgres://%s:%s@%s:%s/%s", user, pass, host, port, dbname)
	if loadBalance == "true" {
		i = fmt.Sprintf("%s?load_balance=%s", i, loadBalance)
		if topologyKeys != "" {
			i = fmt.Sprintf("%s&topology_keys=%s", i, topologyKeys)
			if explicitFallback == "true" {
				i = fmt.Sprintf("%s&fallback_to_topology_keys_only=%s", i, explicitFallback)
			}
		}
		if refreshInterval != "" {
			i = fmt.Sprintf("%s&yb_servers_refresh_interval=%s", i, refreshInterval)
		}
		if failedHostTTL != "" {
			i = fmt.Sprintf("%s&failed_host_reconnect_delay_secs=%s", i, failedHostTTL)
		}
	}
	pool, err := pgxpool.New(ctx, i)
	if err != nil {
		return nil, fmt.Errorf("unable to create connection pool: %w", err)
	}

	return pool, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped error; a DSN parse error names the invalid parameter — fix the source config (host, port, user, password, dbname).
  2. Verify connectivity: run ysqlsh or pg_isready against host:port from the toolbox host; open firewall/security-group rules if blocked.
  3. Check optional DSN parameters (load_balance, topology_keys, refresh_interval, explicit_fallbacks, failed_host_reconnect_delay_secs) for typos or unsupported values for your YugabyteDB version.
  4. Confirm the YugabyteDB cluster (YSQL/ycql pods) is running and the service DNS resolves.
  5. Test credentials directly with ysqlsh -h host -p port -U user -d dbname.

Example fix

// before (config)
host: "yb-tserver.internal", topologyKeys: "region=us-west1" // wrong region
// after
host: "yb-tserver.internal", topologyKeys: "region=us-east1.zone-a"
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight check before configuring the source
import net from 'node:net';
const s = net.createConnection({ host: cfg.host, port: Number(cfg.port) });
s.on('connect', () => s.end());
s.on('error', () => console.error('YugabyteDB host unreachable'));

Prevention

When it happens

Trigger: Initialize is called for the yugabytedb source and pgxpool.New returns an error, e.g., malformed connection parameters (invalid topology_keys or refresh_interval in the DSN), unresolvable hostname, or no reachable YugabyteDB node.

Common situations: Wrong host/port in the toolbox config, typo in connection string query parameters (load_balance, topology_keys, failed_host_reconnect_delay_secs), database not started or firewall blocking port 5433, wrong credentials, Kubernetes service DNS not resolving.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/c9dcf2cf47cf51e0. Report an issue: GitHub.