{"record":{"id":"74c9bb3eeb9ad95d","repo":"googleapis/mcp-toolbox","slug":"unable-to-connect-successfully-w-74c9bb","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/clickhouse/clickhouse.go","lineNumber":75,"sourceCode":"\tPassword string `yaml:\"password\"`\n\tProtocol string `yaml:\"protocol\"`\n\tSecure   bool   `yaml:\"secure\"`\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 := initClickHouseConnectionPool(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.Protocol, r.Secure)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create pool: %w\", err)\n\t}\n\n\terr = pool.PingContext(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 *sql.DB\n}\n\nfunc (s *Source) IsReadOnly() bool {\n\treturn false","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/clickhouse/clickhouse.go#L57-L93","documentation":"After building the pool, Initialize calls PingContext to verify connectivity. If the ping fails, the pool is closed and this error is returned, meaning the ClickHouse server could not be reached or authenticated.","triggerScenarios":"Calling Initialize when pool.PingContext(ctx) fails: server unreachable, wrong credentials, database missing, TLS mismatch, or the context is cancelled/timed out.","commonSituations":"ClickHouse not running, wrong port, wrong user/password, database doesn't exist, secure=false against a TLS-only server, network egress blocked.","solutions":["Check ClickHouse is running and reachable at host:port.","Validate user/password and that the database exists.","Match the secure flag to the server's TLS configuration.","Increase the context timeout if initialization races a slow startup.","Read the wrapped error for the driver's root cause."],"exampleFix":"// before\nr := clickhouse.Config{Host: \"10.0.0.5\", Port: \"8123\", Secure: false}\n// after\nr := clickhouse.Config{Host: \"10.0.0.5\", Port: \"8443\", Secure: true}","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", net.JoinHostPort(r.Host, r.Port), 3*time.Second)\nif err != nil { return fmt.Errorf(\"clickhouse unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to connect successfully\") {\n        // transient: retry with backoff; else surface config error\n        return retryOrSurface(err)\n    }\n    return err\n}","preventionTips":["Ping the server with clickhouse-client before wiring config.","Match the secure flag to server TLS settings.","Use adequate context timeouts for cold starts."],"tags":["clickhouse","ping","connectivity"],"backgroundTag":"ping-failed","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"}