{"record":{"id":"a2617244ecbd83e5","repo":"thanos-io/thanos","slug":"dialing-connection","errorCode":null,"errorMessage":"dialing connection","messagePattern":"dialing connection","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query/endpointset.go","lineNumber":672,"sourceCode":"\n\tmtx      *sync.RWMutex\n\tcc       *grpc.ClientConn\n\taddr     string\n\tisStrict bool\n\n\tcreated  time.Time\n\tmetadata *endpointMetadata\n\tstatus   *EndpointStatus\n\n\tlogger log.Logger\n}\n\n// newEndpointRef creates a new endpointRef with a gRPC channel to the given the IP address.\n// The call to newEndpointRef will return an error if establishing the channel fails.\nfunc (e *EndpointSet) newEndpointRef(spec *GRPCEndpointSpec) (*endpointRef, error) {\n\tconn, err := grpc.NewClient(spec.Addr(), spec.dialOpts...)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"dialing connection\")\n\t}\n\n\treturn &endpointRef{\n\t\tlogger:   e.logger,\n\t\tcreated:  e.now(),\n\t\taddr:     spec.Addr(),\n\t\tisStrict: spec.isStrictStatic,\n\t\tcc:       conn,\n\t\tmtx:      &sync.RWMutex{},\n\t}, nil\n}\n\n// update sets the metadata and status of the endpoint ref based on the info response value and error.\nfunc (er *endpointRef) update(now nowFunc, metadata *endpointMetadata, err error) {\n\ter.mtx.Lock()\n\tdefer er.mtx.Unlock()\n\n\ter.updateMetadata(metadata, err)","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/query/endpointset.go#L654-L690","documentation":"EndpointSet.newEndpointRef creates the gRPC channel (grpc.NewClient) to a discovered endpoint spec. If channel construction fails, the error is wrapped as \"dialing connection\" and the endpoint is not added to the set.","triggerScenarios":"grpc.NewClient(spec.Addr(), spec.dialOpts...) returns an error — typically an invalid target address string (unparsable host:port, bad scheme/resolver) or invalid dial options (bad credentials/TLS config).","commonSituations":"Malformed gRPC endpoint address in store/endpoint configuration (e.g. including http:// scheme in a gRPC address, IPv6 without brackets); invalid TLS credentials supplied via dial options; wrong port.","solutions":["Fix the endpoint address: gRPC targets should be host:port (or dns:///host:port), no scheme like http://.","Use grpc.NewClient with a proper resolver prefix for DNS (dns:///host:port) if needed.","Validate spec.dialOpts (transport credentials) are constructed without error at startup.","Log spec.Addr() and validate with net.SplitHostPort before creating the ref."],"exampleFix":"// before\nspec.Addr() == \"http://sidecar:10901\" // invalid for gRPC\n\n// after\nspec.Addr() == \"sidecar:10901\"\n// or\ntarget := \"dns:///sidecar:10901\"\nconn, err := grpc.NewClient(target, spec.dialOpts...)","handlingStrategy":"validation","validationCode":"host, port, err := net.SplitHostPort(spec.Addr())\nif err != nil {\n\treturn fmt.Errorf(\"invalid gRPC endpoint address %q: %w\", spec.Addr(), err)\n}\nif strings.HasPrefix(spec.Addr(), \"http\") {\n\treturn fmt.Errorf(\"gRPC address %q must not include http scheme\", spec.Addr())\n}","typeGuard":"func validGRPCAddr(addr string) bool {\n\t_, _, err := net.SplitHostPort(addr)\n\treturn err == nil && !strings.Contains(addr, \"://\")\n}","tryCatchPattern":null,"preventionTips":["Use bare host:port (or dns:///host:port) for gRPC targets, never http:// URLs","Validate dial options/TLS credentials at startup before dialing endpoints","Add a connectivity smoke test against each gRPC endpoint in CI/deploy checks"],"tags":["grpc","network","dial","address"],"backgroundTag":"connection-refused","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}