{"record":{"id":"0efbadd261bd561c","repo":"prometheus/node_exporter","slug":"couldn-t-get-tcp6stats-w","errorCode":null,"errorMessage":"couldn't get tcp6stats: %w","messagePattern":"couldn't get tcp6stats: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/tcpstat_linux.go","lineNumber":140,"sourceCode":"\tUID     uint32\n\tInode   uint32\n}\n\nfunc parseInetDiagMsg(b []byte) *InetDiagMsg {\n\treturn (*InetDiagMsg)(unsafe.Pointer(&b[0]))\n}\n\nfunc (c *tcpStatCollector) Update(ch chan<- prometheus.Metric) error {\n\ttcpStats, err := getTCPStats(syscall.AF_INET)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get tcpstats: %w\", err)\n\t}\n\n\t// if enabled ipv6 system\n\tif _, hasIPv6 := os.Stat(procFilePath(\"net/tcp6\")); hasIPv6 == nil {\n\t\ttcp6Stats, err := getTCPStats(syscall.AF_INET6)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"couldn't get tcp6stats: %w\", err)\n\t\t}\n\n\t\tfor st, value := range tcp6Stats {\n\t\t\ttcpStats[st] += value\n\t\t}\n\t}\n\n\tfor st, value := range tcpStats {\n\t\tch <- c.desc.mustNewConstMetric(value, st.String())\n\t}\n\n\treturn nil\n}\n\nfunc getTCPStats(family uint8) (map[tcpConnectionState]float64, error) {\n\tconst TCPFAll = 0xFFF\n\tconst InetDiagInfo = 2\n\tconst SockDiagByFamily = 20","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/tcpstat_linux.go#L122-L158","documentation":"After collecting IPv4 stats, Update checks whether /proc/net/tcp6 exists and, if so, collects IPv6 TCP stats via getTCPStats(syscall.AF_INET6), merging them into the totals. A failure in that IPv6 call is wrapped as \"couldn't get tcp6stats\". The whole scrape fails rather than reporting only IPv4 data.","triggerScenarios":"/proc/net/tcp6 exists (IPv6 enabled) but the AF_INET6 inet_diag request fails: netlink dial error, kernel rejects the sock_diag query for IPv6, or response parsing fails.","commonSituations":"IPv6 enabled in /proc but kernel built without CONFIG_INET6_DIAG; container security policies denying IPv6 netlink queries; unusual IPv6-only sockets confusing older kernels.","solutions":["Verify kernel has CONFIG_INET6_DIAG enabled (`ls /proc/net/tcp6` works but `ss -6` fails suggests this)","Grant netlink capabilities in containers as for the IPv4 case","If IPv6 is intentionally unusable, disable tcpstat via --collector.tcpstat or boot with IPv6 fully disabled so /proc/net/tcp6 disappears","Report upstream if the kernel rejects valid inet_diag IPv6 queries"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(\"/proc/net/tcp6\"); err == nil {\n    if _, err := net.Listen(\"tcp6\", \":0\"); err != nil {\n        // IPv6 present in procfs but not functional — expect tcp6stats failures\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := coll.Update(ch); err != nil {\n    if strings.Contains(err.Error(), \"tcp6stats\") {\n        log.Warn(\"IPv6 tcp stats unavailable\", \"err\", err)\n    }\n}","preventionTips":["Ensure kernel has CONFIG_INET6_DIAG when IPv6 is enabled","Test `ss -6` works in the deployment environment","Disable IPv6 cleanly (so /proc/net/tcp6 disappears) if IPv6 is unsupported","Mirror netlink capability grants to the IPv6 case"],"tags":["tcp","ipv6","netlink","linux"],"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"}