{"record":{"id":"8de880f84c3c22a0","repo":"prometheus/node_exporter","slug":"could-not-get-network-interfaces-w","errorCode":null,"errorMessage":"could not get network interfaces: %w","messagePattern":"could not get network interfaces: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/netdev_common.go","lineNumber":142,"sourceCode":"\n\t\tlabels := []string{\"device\"}\n\t\tlabelValues := []string{dev}\n\t\tif devLabels, exists := netDevLabels[dev]; exists {\n\t\t\tfor labelName, labelValue := range devLabels {\n\t\t\t\tlabels = append(labels, labelName)\n\t\t\t\tlabelValues = append(labelValues, labelValue)\n\t\t\t}\n\t\t}\n\n\t\tfor key, value := range devStats {\n\t\t\tdesc := c.metricDesc(key, labels)\n\t\t\tch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, float64(value), labelValues...)\n\t\t}\n\t}\n\tif *netdevAddressInfo {\n\t\tinterfaces, err := net.Interfaces()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not get network interfaces: %w\", err)\n\t\t}\n\n\t\tdesc := prometheus.NewDesc(prometheus.BuildFQName(namespace, \"network_address\",\n\t\t\t\"info\"), \"node network address by device\",\n\t\t\t[]string{\"device\", \"address\", \"netmask\", \"scope\"}, nil)\n\n\t\tfor _, addr := range getAddrsInfo(interfaces, &c.deviceFilter, c.logger) {\n\t\t\tch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, 1,\n\t\t\t\taddr.device, addr.addr, addr.netmask, addr.scope)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype addrInfo struct {\n\tdevice  string\n\taddr    string\n\tscope   string","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netdev_common.go#L124-L160","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the environment allows interface enumeration: run `ip addr` or `ifconfig` in the same namespace.","Disable the flag if address info is not needed: --collector.netdev.address-info=false (run with --collector.netdev.address-info without enabling, per defaults).","Check seccomp/AppArmor profiles that may block socket(AF_NETLINK) or getifaddrs syscalls.","Inspect the wrapped inner error for the failing syscall.","Restart the exporter if the failure appeared only after long uptime (possible fd/resource leak)."],"exampleFix":"// before: address-info enabled in restricted container\nnode_exporter --collector.netdev.address-info\n// after: disable if not required\nnode_exporter --collector.disable-defaults --collector.netdev","handlingStrategy":"try-catch","validationCode":"// preflight: interface enumeration must succeed before enabling address-info\nif _, err := net.Interfaces(); err != nil {\n\treturn fmt.Errorf(\"environment cannot enumerate interfaces: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := collector.Update(ch)\nif err != nil && strings.Contains(err.Error(), \"could not get network interfaces\") {\n\tlogger.Warn(\"address-info disabled: interface enumeration failed\", \"err\", err)\n\treturn nil\n}","preventionTips":["Enable --collector.netdev.address-info only in environments where getifaddrs works","Review seccomp/AppArmor profiles for socket restrictions","Restart exporter if failures appear only after long uptime (fd/memory exhaustion)","Confirm with `ip addr` that enumeration works in the target namespace"],"tags":["network","go-net","address-info"],"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"}