{"record":{"id":"57552520eb9845c1","repo":"micro/go-micro","slug":"failed-to-get-interfaces","errorCode":null,"errorMessage":"failed to get interfaces","messagePattern":"failed to get interfaces","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/addr/addr.go","lineNumber":53,"sourceCode":"}\n\n// Extract returns a valid IP address. If the address provided is a valid\n// address, it will be returned directly. Otherwise, the available interfaces\n// will be iterated over to find an IP address, preferably private.\nfunc Extract(addr string) (string, error) {\n\t// if addr is already specified then it's directly returned\n\tif len(addr) > 0 && (addr != \"0.0.0.0\" && addr != \"[::]\" && addr != \"::\") {\n\t\treturn addr, nil\n\t}\n\n\tvar (\n\t\taddrs   []net.Addr\n\t\tloAddrs []net.Addr\n\t)\n\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"failed to get interfaces\")\n\t}\n\n\tfor _, iface := range ifaces {\n\t\tifaceAddrs, err := iface.Addrs()\n\t\tif err != nil {\n\t\t\t// ignore error, interface can disappear from system\n\t\t\tcontinue\n\t\t}\n\n\t\tif iface.Flags&net.FlagLoopback != 0 {\n\t\t\tloAddrs = append(loAddrs, ifaceAddrs...)\n\t\t\tcontinue\n\t\t}\n\n\t\taddrs = append(addrs, ifaceAddrs...)\n\t}\n\n\t// Add loopback addresses to the end of the list","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/internal/util/addr/addr.go#L35-L71","documentation":"Extract enumerates the machine's network interfaces via net.Interfaces() to find a non-loopback address. This error wraps a failure of that system call, meaning the Go runtime could not list the host's network interfaces at all.","triggerScenarios":"Calling Extract (directly or via getAddr/Register/Deregister) in environments where net.Interfaces() fails: restricted /sys or /proc access, seccomp/AppArmor profiles blocking socket ioctls, containers lacking NETADMIN-ish capabilities for interface queries, or extremely large numbers of interfaces.","commonSituations":"Running in hardened containers/Kubernetes with restrictive seccomp profiles; minimal Docker images with stripped /sys; sandboxed CI runners; malformed interface state on the host.","solutions":["Read errors.Cause(err) for the syscall errno","Relax container security profile (seccomp/AppArmor) to allow network interface enumeration","Test with `ip link` or `ifconfig` inside the same container to confirm the restriction","Configure the service/advertising address explicitly instead of relying on auto-extraction","Run the container with the needed capabilities or on the host network"],"exampleFix":"// before\naddr, err := addr.Extract(\"\") // fails in restricted container\n// after\n// set --advertise/--server_address explicitly so Extract is not needed\nif addr == \"\" {\n    addr = os.Getenv(\"MICRO_SERVER_ADDRESS\")\n}","handlingStrategy":"fallback","validationCode":"// verify interface enumeration works in this environment\nif _, err := net.Interfaces(); err != nil {\n    // fall back to explicit address from config\n    addr = os.Getenv(\"SERVICE_ADDRESS\")\n}","typeGuard":null,"tryCatchPattern":"advt, err := addr.Extract(\"\")\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to get interfaces\") {\n        advt = os.Getenv(\"SERVICE_ADDRESS\") // configured fallback\n    }\n    if advt == \"\" { return err }\n}","preventionTips":["Set an explicit advertise/server address in containers instead of relying on auto-extract","Test images under your seccomp/AppArmor profile before deploying","Use host networking or grant needed capabilities in restricted environments","Verify with `ip link` inside the container during CI"],"tags":["network","interfaces","environment","container"],"backgroundTag":"network-interface-enumeration-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}