{"record":{"id":"f959a484815c662c","repo":"micro/go-micro","slug":"could-not-determine-host-ip-addresses-for-s","errorCode":null,"errorMessage":"could not determine host IP addresses for %s","messagePattern":"could not determine host IP addresses for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/mdns/zone.go","lineNumber":108,"sourceCode":"\t\t}\n\t\thostName = fmt.Sprintf(\"%s.\", hostName)\n\t}\n\tif err := validateFQDN(hostName); err != nil {\n\t\treturn nil, fmt.Errorf(\"hostName %q is not a fully-qualified domain name: %v\", hostName, err)\n\t}\n\n\tif len(ips) == 0 {\n\t\tvar err error\n\t\tips, err = net.LookupIP(trimDot(hostName))\n\t\tif err != nil {\n\t\t\t// Try appending the host domain suffix and lookup again\n\t\t\t// (required for Linux-based hosts)\n\t\t\ttmpHostName := fmt.Sprintf(\"%s%s\", hostName, domain)\n\n\t\t\tips, err = net.LookupIP(trimDot(tmpHostName))\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not determine host IP addresses for %s\", hostName)\n\t\t\t}\n\t\t}\n\t}\n\tfor _, ip := range ips {\n\t\tif ip.To4() == nil && ip.To16() == nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid IP address in IPs list: %v\", ip)\n\t\t}\n\t}\n\n\treturn &MDNSService{\n\t\tInstance:     instance,\n\t\tService:      service,\n\t\tDomain:       domain,\n\t\tHostName:     hostName,\n\t\tPort:         port,\n\t\tIPs:          ips,\n\t\tTXT:          txt,\n\t\tTTL:          defaultTTL,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/internal/util/mdns/zone.go#L90-L126","documentation":"When no IPs are supplied, NewMDNSService attempts net.LookupIP on the hostname (or hostname+domain as a fallback) to discover A/AAAA records. If that lookup fails, this error reports that no IP addresses could be determined for the host, so A records cannot be published.","triggerScenarios":"Calling NewMDNSService(instance, service, domain, hostName, port, nil/[], txt) on a machine where DNS/mDNS resolution of its own hostname fails — no resolver configured, hostname not in /etc/hosts, or the host has no network interfaces.","commonSituations":"Offline or air-gapped machines; containers whose hostname isn't resolvable; freshly provisioned VMs before /etc/hosts is populated; VPN-only environments where the lookup path is broken.","solutions":["Pass an explicit ips slice (e.g. discovered interface addresses) so no lookup is performed: net.InterfaceAddrs() filtered to IPNet addresses","Ensure the machine's hostname resolves: add it to /etc/hosts or configure DNS","Check network/DNS configuration on the host; the wrapped lookup must succeed for auto-discovery"],"exampleFix":"// before\nsvc, err := NewMDNSService(\"myapp\", \"_http._tcp\", \"local.\", \"\", 8080, nil, nil) // lookup fails offline\n// after\nvar ips []net.IP\nif addrs, err := net.InterfaceAddrs(); err == nil {\n\tfor _, a := range addrs {\n\t\tif ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tips = append(ips, ipnet.IP)\n\t\t}\n\t}\n}\nsvc, err2 := NewMDNSService(\"myapp\", \"_http._tcp\", \"local.\", \"\", 8080, ips, nil)","handlingStrategy":"fallback","validationCode":"func localIPs() []net.IP {\n\tvar ips []net.IP\n\tif addrs, err := net.InterfaceAddrs(); err == nil {\n\t\tfor _, a := range addrs {\n\t\t\tif ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\t\tips = append(ips, ipnet.IP)\n\t\t\t}\n\t\t}\n\t}\n\treturn ips // pass explicitly to skip DNS lookup\n}","typeGuard":"func hasUsableIPs(ips []net.IP) bool {\n\treturn len(ips) > 0\n}","tryCatchPattern":"svc, err := NewMDNSService(instance, service, domain, hostName, port, ips, txt)\nif err != nil {\n\tif strings.Contains(err.Error(), \"could not determine host IP addresses\") {\n\t\t// offline host: fall back to explicit interface addresses or skip registration\n\t\treturn fmt.Errorf(\"pass explicit IPs or fix DNS/hosts resolution: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Discover interface addresses locally (net.InterfaceAddrs) and pass them instead of relying on DNS lookup","Ensure the machine's own hostname resolves (add it to /etc/hosts) in containers and offline hosts","Defer registration until the network is up, or retry registration on failure"],"tags":["network","mdns","dns-lookup","ip-address"],"backgroundTag":"dns-resolution-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}