{"record":{"id":"76ca5a411f35bf18","repo":"prometheus/node_exporter","slug":"net-interfaces-failed-w","errorCode":null,"errorMessage":"net.Interfaces() failed: %w","messagePattern":"net\\.Interfaces\\(\\) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/netdev_darwin.go","lineNumber":34,"sourceCode":"package collector\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"log/slog\"\n\t\"net\"\n\t\"unsafe\"\n\n\t\"golang.org/x/sys/unix\"\n)\n\nfunc getNetDevStats(filter *deviceFilter, logger *slog.Logger) (netDevStats, error) {\n\tnetDev := netDevStats{}\n\n\tifs, err := net.Interfaces()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"net.Interfaces() failed: %w\", err)\n\t}\n\n\tfor _, iface := range ifs {\n\t\tif filter.ignored(iface.Name) {\n\t\t\tlogger.Debug(\"Ignoring device\", \"device\", iface.Name)\n\t\t\tcontinue\n\t\t}\n\n\t\tifaceData, err := getIfaceData(iface.Index)\n\t\tif err != nil {\n\t\t\tlogger.Debug(\"failed to load data for interface\", \"device\", iface.Name, \"err\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tnetDev[iface.Name] = map[string]uint64{\n\t\t\t\"receive_packets\":    ifaceData.Data.Ipackets,\n\t\t\t\"transmit_packets\":   ifaceData.Data.Opackets,\n\t\t\t\"receive_bytes\":      ifaceData.Data.Ibytes,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netdev_darwin.go#L16-L52","documentation":"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.","triggerScenarios":"net.Interfaces() returns an error on darwin — typically a failure of the underlying getifaddrs syscall (memory allocation failure, socket errors, or sandbox restrictions).","commonSituations":"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.","solutions":["Run the exporter outside sandbox restrictions (grant Full Disk Access / network access in macOS security settings as applicable).","Read the wrapped inner error to identify the getifaddrs failure reason.","Test enumeration independently with a tiny Go program calling net.Interfaces() in the same environment.","Retry the scrape; getifaddrs failures are often transient resource issues.","If you do not need netdev metrics on the host, disable the collector: --collector.disable-defaults --collector.<needed>."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight on darwin\nif _, err := net.Interfaces(); err != nil {\n\treturn fmt.Errorf(\"host cannot enumerate interfaces: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := collector.Update(ch)\nif err != nil && strings.Contains(err.Error(), \"net.Interfaces() failed\") {\n\ttime.Sleep(2 * time.Second)\n\treturn collector.Update(ch) // one retry; getifaddrs failures are often transient\n}","preventionTips":["Run the exporter unsandboxed on macOS hosts","Verify net.Interfaces() works in CI/sandbox before enabling netdev there","Monitor consecutive netdev scrape failures before alerting","Keep macOS and Go runtime updated for getifaddrs fixes"],"tags":["darwin","go-net","network"],"backgroundTag":"network-request-failed","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}