{"record":{"id":"b962bc432c61fedf","repo":"jeessy2/ddns-go","slug":"get-interface-s-addresses-failed-v","errorCode":null,"errorMessage":"get interface %s addresses failed: %v","messagePattern":"get interface (.+?) addresses failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"util/http_client_util.go","lineNumber":19,"sourceCode":"package util\n\nimport (\n\t\"context\"\n\t\"crypto/tls\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc getLocalAddrFromInterfaceByNetwork(ifaceName, network string) (string, error) {\n\tiface, err := net.InterfaceByName(ifaceName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"interface %s not found: %v\", ifaceName, err)\n\t}\n\taddrs, err := iface.Addrs()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"get interface %s addresses failed: %v\", ifaceName, err)\n\t}\n\n\thasGlobalUnicast := false\n\tfor _, addr := range addrs {\n\t\tipNet, ok := addr.(*net.IPNet)\n\t\tif !ok || !ipNet.IP.IsGlobalUnicast() {\n\t\t\tcontinue\n\t\t}\n\t\thasGlobalUnicast = true\n\t\tif isIPMatchedNetwork(ipNet.IP, network) {\n\t\t\treturn ipNet.IP.String(), nil\n\t\t}\n\t}\n\tif hasGlobalUnicast && (network == \"tcp4\" || network == \"tcp6\") {\n\t\treturn \"\", fmt.Errorf(\"interface %s has no usable %s address\", ifaceName, network)\n\t}\n\treturn \"\", fmt.Errorf(\"interface %s has no usable global-unicast address\", ifaceName)\n}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/util/http_client_util.go#L1-L37","documentation":"Returned by getLocalAddrFromInterfaceByNetwork (util/http_client_util.go:19) when iface.Addrs() fails after the interface itself was found — meaning the OS refused to enumerate addresses on that interface. The interface may exist but be down, lack permissions context, or be in a broken state. As with the other binding errors, CreateBoundNoProxyHTTPClient logs it and falls back to the default no-proxy client.","triggerScenarios":"Calling CreateBoundNoProxyHTTPClient on an interface that exists but is DOWN or in an error state; OS-level failure enumerating addresses (driver issue, netlink socket failure, resource exhaustion); race where the NIC is being reconfigured mid-call.","commonSituations":"Configured NIC is administratively down (cable unplugged, `ip link set eth0 down`); VPN/virtual adapters in a half-initialized state; containers or restricted environments where address enumeration fails; NIC flapping during startup before the network is fully up.","solutions":["Bring the interface up (`ip link set <iface> up`) and confirm it has addresses via `ip addr show <iface>`","Check `dmesg`/system logs for driver or NIC errors on that interface","Retry after the network is fully initialized (e.g. wait for network-online target in systemd services)","Clear the interface binding config to use the default client while debugging"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Go: verify the interface is up AND has a usable address before binding\niface, err := net.InterfaceByName(ifaceName)\nif err != nil { return err }\nif iface.Flags&net.FlagUp == 0 {\n    return fmt.Errorf(\"interface %s is down\", ifaceName)\n}\naddrs, err := iface.Addrs()\nif err != nil || len(addrs) == 0 {\n    return fmt.Errorf(\"interface %s has no enumerable addresses\", ifaceName)\n}","typeGuard":"func interfaceReady(name string) bool {\n    iface, err := net.InterfaceByName(name)\n    if err != nil || iface.Flags&net.FlagUp == 0 {\n        return false\n    }\n    addrs, err := iface.Addrs()\n    return err == nil && len(addrs) > 0\n}","tryCatchPattern":"// Go: rely on the library's built-in fallback, but log loudly in your wrapper\nclient := util.CreateBoundNoProxyHTTPClient(network, ifaceName)\n// library already fell back if binding failed; detect the degraded path:\nif !interfaceReady(ifaceName) {\n    log.Printf(\"WARNING: interface %s not ready, traffic will NOT be bound to it\", ifaceName)\n}","preventionTips":["Check the interface is UP and has addresses (ip addr show) before enabling binding","Ensure network is fully initialized before starting (systemd network-online, etc.)","Watch for VPN/virtual adapters in half-up states — validate with interfaceReady()","Monitor NIC state in long-running services and re-create the client when the interface recovers"],"tags":["network","interface","go","configuration"],"backgroundTag":"network-interface-not-found","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}