prometheus/node_exporter · error

could not get network interfaces

Error message

could not get network interfaces: %w

What it means

When --collector.netdev.address-info is enabled, the netdev collector additionally calls Go's net.Interfaces() to enumerate interfaces and their addresses for the node_network_address_info metric. Any failure from that standard-library call is wrapped as 'could not get network interfaces' and aborts the Update.

Solutions

  1. Verify the environment allows interface enumeration: run `ip addr` or `ifconfig` in the same namespace.
  2. Disable the flag if address info is not needed: --collector.netdev.address-info=false (run with --collector.netdev.address-info without enabling, per defaults).
  3. Check seccomp/AppArmor profiles that may block socket(AF_NETLINK) or getifaddrs syscalls.
  4. Inspect the wrapped inner error for the failing syscall.
  5. Restart the exporter if the failure appeared only after long uptime (possible fd/resource leak).

Example fix

// before: address-info enabled in restricted container
node_exporter --collector.netdev.address-info
// after: disable if not required
node_exporter --collector.disable-defaults --collector.netdev
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: interface enumeration must succeed before enabling address-info
if _, err := net.Interfaces(); err != nil {
	return fmt.Errorf("environment cannot enumerate interfaces: %w", err)
}

Try / catch

err := collector.Update(ch)
if err != nil && strings.Contains(err.Error(), "could not get network interfaces") {
	logger.Warn("address-info disabled: interface enumeration failed", "err", err)
	return nil
}

Prevention

When it happens

Trigger: net.Interfaces() fails during the address-info phase of Update — OS syscall failure enumerating interfaces (e.g. socket creation for getifaddrs blocked, or memory/resource exhaustion).

Common situations: Address-info flag enabled in hardened containers where getifaddrs/netlink enumeration is blocked by seccomp; resource exhaustion in long-running processes (fd/memory); unusual network namespace states.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/8de880f84c3c22a0. Report an issue: GitHub.

Appendix: source

Thrown at collector/netdev_common.go:142

		labels := []string{"device"}
		labelValues := []string{dev}
		if devLabels, exists := netDevLabels[dev]; exists {
			for labelName, labelValue := range devLabels {
				labels = append(labels, labelName)
				labelValues = append(labelValues, labelValue)
			}
		}

		for key, value := range devStats {
			desc := c.metricDesc(key, labels)
			ch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, float64(value), labelValues...)
		}
	}
	if *netdevAddressInfo {
		interfaces, err := net.Interfaces()
		if err != nil {
			return fmt.Errorf("could not get network interfaces: %w", err)
		}

		desc := prometheus.NewDesc(prometheus.BuildFQName(namespace, "network_address",
			"info"), "node network address by device",
			[]string{"device", "address", "netmask", "scope"}, nil)

		for _, addr := range getAddrsInfo(interfaces, &c.deviceFilter, c.logger) {
			ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, 1,
				addr.device, addr.addr, addr.netmask, addr.scope)
		}
	}
	return nil
}

type addrInfo struct {
	device  string
	addr    string
	scope   string

View on GitHub (pinned to 17ddd77c59)