micro/go-micro · error
failed to get interfaces
Error message
failed to get interfaces
What it means
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.
Source
Thrown at internal/util/addr/addr.go:53
}
// Extract returns a valid IP address. If the address provided is a valid
// address, it will be returned directly. Otherwise, the available interfaces
// will be iterated over to find an IP address, preferably private.
func Extract(addr string) (string, error) {
// if addr is already specified then it's directly returned
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
return addr, nil
}
var (
addrs []net.Addr
loAddrs []net.Addr
)
ifaces, err := net.Interfaces()
if err != nil {
return "", errors.Wrap(err, "failed to get interfaces")
}
for _, iface := range ifaces {
ifaceAddrs, err := iface.Addrs()
if err != nil {
// ignore error, interface can disappear from system
continue
}
if iface.Flags&net.FlagLoopback != 0 {
loAddrs = append(loAddrs, ifaceAddrs...)
continue
}
addrs = append(addrs, ifaceAddrs...)
}
// Add loopback addresses to the end of the listView on GitHub (pinned to 24529f1404)
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
Example fix
// before
addr, err := addr.Extract("") // fails in restricted container
// after
// set --advertise/--server_address explicitly so Extract is not needed
if addr == "" {
addr = os.Getenv("MICRO_SERVER_ADDRESS")
} Defensive patterns
Strategy: fallback
Validate before calling
// verify interface enumeration works in this environment
if _, err := net.Interfaces(); err != nil {
// fall back to explicit address from config
addr = os.Getenv("SERVICE_ADDRESS")
} Try / catch
advt, err := addr.Extract("")
if err != nil {
if strings.Contains(err.Error(), "failed to get interfaces") {
advt = os.Getenv("SERVICE_ADDRESS") // configured fallback
}
if advt == "" { return err }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Running in hardened containers/Kubernetes with restrictive seccomp profiles; minimal Docker images with stripped /sys; sandboxed CI runners; malformed interface state on the host.
Related errors
- ErrIPNotFound
- failed to join multicast group on all interfaces
- failed to join multicast group on all interfaces
- API error: nil response
- failed request
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/57552520eb9845c1.
Report an issue: GitHub.