{"record":{"id":"d880f23db4bc23a3","repo":"thanos-io/thanos","slug":"missing-port-in-address-given-for-dnsdualstack-loo","errorCode":null,"errorMessage":"missing port in address given for dnsdualstack lookup: %v","messagePattern":"missing port in address given for dnsdualstack lookup: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/discovery/dns/resolver.go","lineNumber":138,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Do A lookup for the domain in SRV answer.\n\t\t\tresIPs, err := s.resolver.LookupIPAddr(ctx, rec.Target)\n\t\t\tif err != nil {\n\t\t\t\tif !s.resolver.IsNotFound(err) {\n\t\t\t\t\treturn nil, errors.Wrapf(err, \"lookup IP addresses %q\", host)\n\t\t\t\t}\n\t\t\t\tif len(resIPs) == 0 {\n\t\t\t\t\tlevel.Error(s.logger).Log(\"msg\", \"failed to lookup IP addresses\", \"srv\", host, \"a\", rec.Target, \"err\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, resIP := range resIPs {\n\t\t\t\tres = append(res, appendScheme(scheme, net.JoinHostPort(resIP.String(), resPort)))\n\t\t\t}\n\t\t}\n\tcase ADualStack:\n\t\tif port == \"\" {\n\t\t\treturn nil, errors.Errorf(\"missing port in address given for dnsdualstack lookup: %v\", name)\n\t\t}\n\t\tvar ips []net.IPAddr\n\t\tlookupErrs := errutil.MultiError{}\n\n\t\tfor _, network := range []string{\"ip6\", \"ip4\"} {\n\t\t\taddrs, err := s.resolver.LookupIPAddrByNetwork(ctx, network, host)\n\t\t\tif err != nil {\n\t\t\t\tif !s.resolver.IsNotFound(err) {\n\t\t\t\t\tlookupErrs.Add(err)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tips = append(ips, addrs...)\n\t\t}\n\n\t\tif err := lookupErrs.Err(); len(ips) == 0 && err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"lookup IP addresses (dual-stack) %q\", host)\n\t\t}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/discovery/dns/resolver.go#L120-L156","documentation":"The DNS service-discovery resolver (Resolve in pkg/discovery/dns/resolver.go) supports A, SRV, and ADualStack lookup schemes. The ADualStack scheme performs IPv6+IPv4 lookups of a hostname and joins each resolved IP with a port. This error is thrown because the ADualStack scheme requires an explicit port, but the target address contained only a host (empty port after parsing), so the resolver refuses to guess a port.","triggerScenarios":"Calling Resolve with an ADualStack-scheme address whose host has no port, e.g. 'dnsdualstack+http://myhost/prefix' instead of 'dnsdualstack+http://myhost:9090/prefix'; also when the port portion is empty or stripped by earlier URL parsing.","commonSituations":"Misconfigured Prometheus/Thanos dns sd_configs; copying an SRV-style config (where ports come from DNS) and switching the scheme to ADualStack without adding a port; config templates where the port variable renders empty.","solutions":["Add an explicit port to the address used with the ADualStack scheme (e.g. host:9090).","If ports should come from DNS SRV records, use the SRV scheme instead of ADualStack.","Check the config template/rendering pipeline so the port variable is not empty at render time."],"exampleFix":"// before\nres, err := resolver.Resolve(ctx, []string{\"dnsdualstack+http://prometheus.monitoring.svc\"})\n// after\nres, err := resolver.Resolve(ctx, []string{\"dnsdualstack+http://prometheus.monitoring.svc:9090\"})","handlingStrategy":"validation","validationCode":"func validateDualStackAddr(addr string) error {\n    _, port, err := net.SplitHostPort(addr)\n    if err != nil || port == \"\" {\n        return fmt.Errorf(\"ADualStack scheme requires explicit host:port, got %q\", addr)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a numeric port in dnsdualstack-scheme addresses.","Use the SRV scheme instead when ports should come from DNS records.","Render address templates with a fallback default port.","Add a unit test asserting every configured address parses via net.SplitHostPort."],"tags":["dns","service-discovery","configuration","network"],"backgroundTag":"missing-required-argument","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"}