prometheus/node_exporter · error

net.Interfaces() failed

Error message

net.Interfaces() failed: %w

What it means

On darwin, getNetDevStats enumerates interfaces using Go's net.Interfaces(); a failure is wrapped as 'net.Interfaces() failed: %w'. This is the macOS/BSD path of the netdev collector — there is no /proc/net/dev here, so interface enumeration is the sole source of device stats.

Solutions

  1. Run the exporter outside sandbox restrictions (grant Full Disk Access / network access in macOS security settings as applicable).
  2. Read the wrapped inner error to identify the getifaddrs failure reason.
  3. Test enumeration independently with a tiny Go program calling net.Interfaces() in the same environment.
  4. Retry the scrape; getifaddrs failures are often transient resource issues.
  5. If you do not need netdev metrics on the host, disable the collector: --collector.disable-defaults --collector.<needed>.
Defensive patterns

Strategy: retry

Validate before calling

// preflight on darwin
if _, err := net.Interfaces(); err != nil {
	return fmt.Errorf("host cannot enumerate interfaces: %w", err)
}

Try / catch

err := collector.Update(ch)
if err != nil && strings.Contains(err.Error(), "net.Interfaces() failed") {
	time.Sleep(2 * time.Second)
	return collector.Update(ch) // one retry; getifaddrs failures are often transient
}

Prevention

When it happens

Trigger: net.Interfaces() returns an error on darwin — typically a failure of the underlying getifaddrs syscall (memory allocation failure, socket errors, or sandbox restrictions).

Common situations: macOS sandboxed/test environments where the exporter binary lacks network-configuration read permissions; running inside restricted CI VMs; rare kernel/resource failures on macOS hosts.

Related errors


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

Appendix: source

Thrown at collector/netdev_darwin.go:34

package collector

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"log/slog"
	"net"
	"unsafe"

	"golang.org/x/sys/unix"
)

func getNetDevStats(filter *deviceFilter, logger *slog.Logger) (netDevStats, error) {
	netDev := netDevStats{}

	ifs, err := net.Interfaces()
	if err != nil {
		return nil, fmt.Errorf("net.Interfaces() failed: %w", err)
	}

	for _, iface := range ifs {
		if filter.ignored(iface.Name) {
			logger.Debug("Ignoring device", "device", iface.Name)
			continue
		}

		ifaceData, err := getIfaceData(iface.Index)
		if err != nil {
			logger.Debug("failed to load data for interface", "device", iface.Name, "err", err)
			continue
		}

		netDev[iface.Name] = map[string]uint64{
			"receive_packets":    ifaceData.Data.Ipackets,
			"transmit_packets":   ifaceData.Data.Opackets,
			"receive_bytes":      ifaceData.Data.Ibytes,

View on GitHub (pinned to 17ddd77c59)