{"record":{"id":"450f1a55fef9f91c","repo":"googleapis/mcp-toolbox","slug":"unable-to-connect-successfully-w-450f1a","errorCode":null,"errorMessage":"unable to connect successfully: %w","messagePattern":"unable to connect successfully: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/yugabytedb/yugabytedb.go","lineNumber":74,"sourceCode":"\tYBServersRefreshInterval        string `yaml:\"ybServersRefreshInterval\"`\n\tFallBackToTopologyKeysOnly      string `yaml:\"fallbackToTopologyKeysOnly\"`\n\tFailedHostReconnectDelaySeconds string `yaml:\"failedHostReconnectDelaySecs\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tpool, err := initYugabyteDBConnectionPool(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.LoadBalance, r.TopologyKeys, r.YBServersRefreshInterval, r.FallBackToTopologyKeysOnly, r.FailedHostReconnectDelaySeconds)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create pool: %w\", err)\n\t}\n\n\terr = pool.Ping(ctx)\n\tif err != nil {\n\t\tpool.Close()\n\t\treturn nil, fmt.Errorf(\"unable to connect successfully: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tPool:   pool,\n\t}\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {\n\tConfig\n\tPool *pgxpool.Pool\n}\n\nfunc (s *Source) IsReadOnly() bool {\n\treturn false","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/yugabytedb/yugabytedb.go#L56-L92","documentation":"After successfully creating the pgx pool, YugabyteDB Config.Initialize calls pool.Ping(ctx) to verify live connectivity. A failed ping — server unreachable, auth rejected, TLS mismatch, DNS failure — closes the pool and returns 'unable to connect successfully: %w'. Unlike 1027, the pool config was valid but no database could actually be reached.","triggerScenarios":"pool.Ping(ctx) fails during Initialize: Yugabyte/Postgres server down or unreachable at host:port, wrong user/password, database does not exist, TLS required but not configured, or firewall/network partition between the toolbox and the cluster.","commonSituations":"Database container not started or wrong Docker network; incorrect credentials in tools.yaml; connecting to a TLS-only cluster without sslmode settings; typo'd database name; Yugabyte node down while topology points only at it.","solutions":["Test connectivity: 'psql -h <host> -p <port> -U <user> -d <database>' with the same credentials","Verify the Yugabyte cluster is running and reachable (docker network, VPC, firewall rules)","Check username/password/database are correct for the target cluster","Add correct TLS/sslmode configuration if the server requires TLS","Read the wrapped '%w' cause to distinguish auth failure vs network failure"],"exampleFix":"// before\nsources:\n  yugabyte:\n    kind: yugabytedb\n    host: 127.0.0.1\n    port: 5433\n    database: wrongdb\n// after\nsources:\n  yugabyte:\n    kind: yugabytedb\n    host: 127.0.0.1\n    port: 5433\n    database: yugabyte","handlingStrategy":"validation","validationCode":"// Pre-flight connectivity check using the same credentials\nimport net from \"net\";\nconst s = net.createConnection({ host: cfg.host, port: cfg.port });\ns.setTimeout(5000);\ns.on(\"connect\", () => { console.log(\"reachable\"); s.end(); });\ns.on(\"error\", (e) => { throw new Error(`Cannot reach ${cfg.host}:${cfg.port}: ${e.message}`); });\ns.on(\"timeout\", () => { throw new Error(\"Connection timed out\"); });","typeGuard":null,"tryCatchPattern":"try {\n  await startToolbox();\n} catch (err) {\n  if (String(err).includes(\"unable to connect successfully\")) {\n    console.error(\"Yugabyte ping failed — check server uptime, network, and credentials:\", err.cause ?? err.message);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Health-check the cluster (ysqlsh -c 'SELECT 1') before launching the toolbox","Verify Docker/VPC networking so the toolbox can reach the database host","Test credentials manually with psql/ysqlsh before putting them in config","Configure TLS/sslmode when the cluster requires encrypted connections","Add readiness checks so dependent services wait for Yugabyte to be up"],"tags":["yugabytedb","postgres","connection","ping","network"],"backgroundTag":"connection-refused","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}