{"record":{"id":"201090403cdabe99","repo":"AlexxIT/go2rtc","slug":"can-t-resolve-s-201090","errorCode":null,"errorMessage":"can't resolve: %s","messagePattern":"can't resolve: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/webrtc/helpers.go","lineNumber":181,"sourceCode":"\tif strings.HasPrefix(address, \"stun:\") {\n\t\tip, err := GetCachedPublicIP()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn ip.String() + address[4:], nil\n\t}\n\n\tif IsIP(address) {\n\t\treturn address, nil\n\t}\n\n\ti := strings.IndexByte(address, ':')\n\tips, err := net.LookupIP(address[:i])\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(ips) == 0 {\n\t\treturn \"\", fmt.Errorf(\"can't resolve: %s\", address)\n\t}\n\n\treturn ips[0].String() + address[i:], nil\n}\n\n// GetPublicIP example from https://github.com/pion/stun\nfunc GetPublicIP(address string) (net.IP, error) {\n\tconn, err := net.Dial(\"udp\", address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc, err := stun.NewClient(conn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = conn.SetDeadline(time.Now().Add(time.Second * 3)); err != nil {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/webrtc/helpers.go#L163-L199","documentation":"Returned by the public LookupIP helper in pkg/webrtc/helpers.go. It splits the address at the last-seen ':' separator, performs net.LookupIP on the host part, and if the lookup succeeds but returns zero IPs, it reports that the host cannot be resolved. It means the resolver returned no addresses for the hostname embedded in the WebRTC address.","triggerScenarios":"Calling LookupIP with an \"host:port\"-style address whose host part is a hostname that DNS resolves to an empty answer (e.g. an NAPTR/A-record-less name), or a malformed host that yields no records despite no lookup error.","commonSituations":"SDP candidates or config URLs referencing internal hostnames not present in DNS; stale mDNS/local names after the camera went offline; DNS server answering NOERROR with zero records; typo'd host in webrtc config.","solutions":["Verify the hostname resolves with dig/nslookup (or getent hosts) on the same machine","Check /etc/resolv.conf and DNS server reachability; try a public resolver to compare","Use an IP literal instead of a hostname in the WebRTC/candidate URL if the host is static","Confirm the device actually publishes its DNS record (mDNS/local zone) and is online","Inspect the address format — ensure there is a ':' separator so the host part is extracted correctly"],"exampleFix":"// before\nip, err := webrtc.LookupIP(\"dead-camera-host.local:8555\") // zero IPs -> \"can't resolve\"\n// after\nif _, err := net.LookupHost(\"dead-camera-host.local\"); err != nil || len(hostIPs) == 0 {\n    // fall back to IP literal or fix DNS first\n}\nip, err := webrtc.LookupIP(\"192.168.1.42:8555\")","handlingStrategy":"validation","validationCode":"// Go: verify the host resolves before calling LookupIP\nhost := address[:strings.IndexByte(address, ':')]\nips, err := net.LookupHost(host)\nif err != nil || len(ips) == 0 {\n    return fmt.Errorf(\"host %q unresolvable, use IP or fix DNS\", host)\n}","typeGuard":"func isResolvable(host string) bool { ips, err := net.LookupHost(host); return err == nil && len(ips) > 0 }","tryCatchPattern":"ip, err := webrtc.LookupIP(addr)\nif err != nil {\n    log.Warnf(\"lookup failed for %s: %v; falling back to literal IP\", addr, err)\n    ip = fallbackIP\n}","preventionTips":["Use IP literals for static devices in candidate URLs","Run dig/nslookup during deployment to verify DNS entries","Keep local DNS/mDNS zones healthy for .local names","Monitor resolv.conf and DNS server reachability"],"tags":["dns","webrtc","network","resolution"],"backgroundTag":"dns-resolution-failed","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}