{"id":"c44b05f77f1e2322","repo":"jackc/pgx","slug":"hostname-resolving-error-w","errorCode":null,"errorMessage":"hostname resolving error: %w","messagePattern":"hostname resolving error: %w","errorType":"exception","errorClass":"ConnectError","httpStatus":null,"severity":"error","filePath":"pgconn/pgconn.go","lineNumber":158,"sourceCode":"// If config.Fallbacks are present they will sequentially be tried in case of error establishing network connection. An\n// authentication error will terminate the chain of attempts (like libpq:\n// https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS) and be returned as the error.\nfunc ConnectConfig(ctx context.Context, config *Config) (*PgConn, error) {\n\t// Default values are set in ParseConfig. Enforce initial creation by ParseConfig rather than setting defaults from\n\t// zero values.\n\tif !config.createdByParseConfig {\n\t\tpanic(\"config must be created by ParseConfig\")\n\t}\n\n\tvar allErrors []error\n\n\tconnectConfigs, errs := buildConnectOneConfigs(ctx, config)\n\tif len(errs) > 0 {\n\t\tallErrors = append(allErrors, errs...)\n\t}\n\n\tif len(connectConfigs) == 0 {\n\t\treturn nil, &ConnectError{Config: config, err: fmt.Errorf(\"hostname resolving error: %w\", errors.Join(allErrors...))}\n\t}\n\n\tpgConn, errs := connectPreferred(ctx, config, connectConfigs)\n\tif len(errs) > 0 {\n\t\tallErrors = append(allErrors, errs...)\n\t\treturn nil, &ConnectError{Config: config, err: errors.Join(allErrors...)}\n\t}\n\n\tif config.AfterConnect != nil {\n\t\terr := config.AfterConnect(ctx, pgConn)\n\t\tif err != nil {\n\t\t\tpgConn.conn.Close()\n\t\t\treturn nil, &ConnectError{Config: config, err: fmt.Errorf(\"AfterConnect error: %w\", err)}\n\t\t}\n\t}\n\n\treturn pgConn, nil\n}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/pgconn.go#L140-L176","documentation":"Error \"hostname resolving error: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/pgconn.go:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}