{"record":{"id":"67f8fe05cc4bb7bd","repo":"k3s-io/k3s","slug":"can-t-find-ip-for-interface-s","errorCode":null,"errorMessage":"can't find ip for interface %s","messagePattern":"can't find ip for interface (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/net.go","lineNumber":312,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tif ip.IsGlobalUnicast() {\n\t\t\tglobalUnicasts = append(globalUnicasts, ip.String())\n\t\t}\n\t}\n\n\tif len(globalUnicasts) > 1 {\n\t\treturn \"\", fmt.Errorf(\"multiple global unicast addresses defined for %s, please set ip from one of %v\", ifaceName, globalUnicasts)\n\t}\n\tif len(globalUnicasts) == 1 && len(globalUnicastsIPv6) == 0 {\n\t\treturn globalUnicasts[0], nil\n\t} else if len(globalUnicastsIPv6) > 0 && len(globalUnicasts) == 1 {\n\t\treturn globalUnicasts[0] + \",\" + globalUnicastsIPv6[0], nil\n\t} else if len(globalUnicastsIPv6) > 0 {\n\t\treturn globalUnicastsIPv6[0], nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"can't find ip for interface %s\", ifaceName)\n}\n\ntype multiListener struct {\n\tlisteners []net.Listener\n\tclosing   chan struct{}\n\tconns     chan acceptRes\n}\n\ntype acceptRes struct {\n\tconn net.Conn\n\terr  error\n}\n\n// explicit interface check\nvar _ net.Listener = &multiListener{}\n\nvar loopbacks = []string{\"127.0.0.1\", \"::1\"}\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/util/net.go#L294-L330","documentation":"Fallback error when the interface is found and up but has no global unicast IPv4 and no global unicast IPv6 address: none of the branches that return an address matched, so there is nothing to return. Loopback and link-local addresses (169.254.x.x, fe80::) are deliberately excluded.","triggerScenarios":"The interface is up but only carries link-local or loopback addresses: DHCP failed or has not run yet, the static IP was not applied yet, or the interface only got an APIPA 169.254.x.x address.","commonSituations":"VMs booting before DHCP completes; interfaces configured after the service starts; agent containers that see the interface before the host assigns its address; misrouted VLANs where DHCP never answers.","solutions":["Check what is assigned: ip addr show <iface> - is there a non-169.254/non-fe80 address?","Fix address acquisition (DHCP client running, static config applied, VLAN correct) and restart the service","If the address arrives late, delay the component until the network is online (network-online.target, readiness checks)","Alternatively set the node IP explicitly via config instead of deriving it from this interface"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func waitForGlobalUnicast(name string, timeout time.Duration) error {\n\tdeadline := time.Now().Add(timeout)\n\tfor time.Now().Before(deadline) {\n\t\tiface, err := net.InterfaceByName(name)\n\t\tif err == nil && iface.Flags&net.FlagUp != 0 {\n\t\t\taddrs, _ := iface.Addrs()\n\t\t\tfor _, a := range addrs {\n\t\t\t\tif ip, _, err := net.ParseCIDR(a.String()); err == nil && ip.IsGlobalUnicast() {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn fmt.Errorf(\"interface %s never got a global unicast address\", name)\n}","typeGuard":null,"tryCatchPattern":"ip, err := util.GetIPFromInterface(name)\nif err != nil && strings.Contains(err.Error(), \"can't find ip for interface\") {\n\t// DHCP/addressing may still be converging: surface which interface and check\n\t// `ip addr show <iface>` for link-local-only state before retrying\n}\nif err != nil {\n\treturn \"\", err\n}","preventionTips":["Ensure DHCP is reliable (or use static IPs) on the interface the node derives its IP from","Delay startup until the network is online instead of racing address assignment","Treat 169.254.x.x on the interface as a DHCP failure signal","Set node-ip explicitly when the preferred interface has no simple unicast address"],"tags":["go","network","interface","dhcp","address-missing"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}