prometheus/node_exporter · error

failed to get IPv6 sockstat data

Error message

failed to get IPv6 sockstat data: %w

What it means

The sockstat collector reads /proc/net/sockstat6 via fs.NetSockstat6(). Errors other than os.ErrNotExist are wrapped as 'failed to get IPv6 sockstat data'. A missing file is expected on IPv6-disabled kernels (logged and skipped); any other error is a genuine read/parse failure.

Solutions

  1. Verify /proc/net/sockstat6 is readable by the exporter user and inspect LSM/seccomp denials
  2. If IPv6 is intentionally absent, ensure the file is simply missing (ErrNotExist is handled gracefully); fix the underlying read error otherwise
  3. Update github.com/prometheus/procfs if the kernel output format changed

Example fix

// verify access
sudo -u node_exporter cat /proc/net/sockstat6
// if the kernel truly lacks IPv6, the collector skips silently; only unexpected errors need fixing
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check before scraping IPv6 sockstat
if _, err := os.Stat("/proc/net/sockstat6"); err != nil && !os.IsNotExist(err) {
	// unexpected access problem; fix permissions before enabling
}

Try / catch

if err := collector.Update(ch); err != nil {
	if strings.Contains(err.Error(), "failed to get IPv6 sockstat data") {
		logger.Warn("IPv6 sockstat unavailable", "err", err)
	} else {
		return err
	}
}

Prevention

When it happens

Trigger: fs.NetSockstat6() returning a non-ErrNotExist error during Update: permission denial or procfs parse failure on /proc/net/sockstat6.

Common situations: Security modules blocking /proc/net reads; partially disabled IPv6 builds where sockstat6 exists but has unexpected content; container runtimes masking procfs entries.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at collector/sockstat_linux.go:70

	}

	// If IPv4 and/or IPv6 are disabled on this kernel, handle it gracefully.
	stat4, err := fs.NetSockstat()
	switch {
	case err == nil:
	case errors.Is(err, os.ErrNotExist):
		c.logger.Debug("IPv4 sockstat statistics not found, skipping")
	default:
		return fmt.Errorf("failed to get IPv4 sockstat data: %w", err)
	}

	stat6, err := fs.NetSockstat6()
	switch {
	case err == nil:
	case errors.Is(err, os.ErrNotExist):
		c.logger.Debug("IPv6 sockstat statistics not found, skipping")
	default:
		return fmt.Errorf("failed to get IPv6 sockstat data: %w", err)
	}

	stats := []struct {
		isIPv6 bool
		stat   *procfs.NetSockstat
	}{
		{
			stat: stat4,
		},
		{
			isIPv6: true,
			stat:   stat6,
		},
	}

	for _, s := range stats {
		c.update(ch, s.isIPv6, s.stat)
	}

View on GitHub (pinned to 17ddd77c59)