jeessy2/ddns-go · warning

get interface %s addresses failed: %v

Error message

get interface %s addresses failed: %v

What it means

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.

Source

Thrown at util/http_client_util.go:19

package util

import (
	"context"
	"crypto/tls"
	"fmt"
	"net"
	"net/http"
	"time"
)

func getLocalAddrFromInterfaceByNetwork(ifaceName, network string) (string, error) {
	iface, err := net.InterfaceByName(ifaceName)
	if err != nil {
		return "", fmt.Errorf("interface %s not found: %v", ifaceName, err)
	}
	addrs, err := iface.Addrs()
	if err != nil {
		return "", fmt.Errorf("get interface %s addresses failed: %v", ifaceName, err)
	}

	hasGlobalUnicast := false
	for _, addr := range addrs {
		ipNet, ok := addr.(*net.IPNet)
		if !ok || !ipNet.IP.IsGlobalUnicast() {
			continue
		}
		hasGlobalUnicast = true
		if isIPMatchedNetwork(ipNet.IP, network) {
			return ipNet.IP.String(), nil
		}
	}
	if hasGlobalUnicast && (network == "tcp4" || network == "tcp6") {
		return "", fmt.Errorf("interface %s has no usable %s address", ifaceName, network)
	}
	return "", fmt.Errorf("interface %s has no usable global-unicast address", ifaceName)
}

View on GitHub (pinned to 5874c2e666)

Solutions

  1. Bring the interface up (`ip link set <iface> up`) and confirm it has addresses via `ip addr show <iface>`
  2. Check `dmesg`/system logs for driver or NIC errors on that interface
  3. Retry after the network is fully initialized (e.g. wait for network-online target in systemd services)
  4. Clear the interface binding config to use the default client while debugging
Defensive patterns

Strategy: validation

Validate before calling

// Go: verify the interface is up AND has a usable address before binding
iface, err := net.InterfaceByName(ifaceName)
if err != nil { return err }
if iface.Flags&net.FlagUp == 0 {
    return fmt.Errorf("interface %s is down", ifaceName)
}
addrs, err := iface.Addrs()
if err != nil || len(addrs) == 0 {
    return fmt.Errorf("interface %s has no enumerable addresses", ifaceName)
}

Type guard

func interfaceReady(name string) bool {
    iface, err := net.InterfaceByName(name)
    if err != nil || iface.Flags&net.FlagUp == 0 {
        return false
    }
    addrs, err := iface.Addrs()
    return err == nil && len(addrs) > 0
}

Try / catch

// Go: rely on the library's built-in fallback, but log loudly in your wrapper
client := util.CreateBoundNoProxyHTTPClient(network, ifaceName)
// library already fell back if binding failed; detect the degraded path:
if !interfaceReady(ifaceName) {
    log.Printf("WARNING: interface %s not ready, traffic will NOT be bound to it", ifaceName)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03). Data as JSON: /api/errors/b962bc432c61fedf. Report an issue: GitHub.