prometheus/node_exporter · error
failed to open procfs
Error message
failed to open procfs: %w
What it means
NewNetStatCollector initializes the Linux netstat collector by opening the procfs filesystem at the path given by the --path.procfs flag via procfs.NewFS. If procfs cannot be opened/mounted at that path, the collector constructor fails with this wrapped error and the collector is not registered.
Solutions
- Ensure /proc exists and is a mounted procfs filesystem (mount | grep proc).
- Check the --path.procfs flag points at the correct procfs root (default /proc).
- In containers, mount /proc into the container (e.g. docker run -v /proc:/host/proc:ro and --path.procfs=/host/proc).
- Verify filesystem permissions allow the node_exporter user to read the procfs path.
Example fix
// before
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
// after (fail fast with an actionable hint)
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs at %q (is it mounted? is --path.procfs correct?): %w", *procPath, err)
} Defensive patterns
Strategy: validation
Validate before calling
import "os"
// Call before starting the collector:
if st, err := os.Stat(*procPath); err != nil || !st.IsDir() {
// fail fast: procfs path missing or not a directory
} Type guard
null
Try / catch
// Wrap collector construction and fail startup with context
if _, err := NewNetStatCollector(logger); err != nil {
logger.Error("netstat collector init failed", "err", err)
os.Exit(1)
} Prevention
- Always mount /proc (read-only is fine) in containers running the exporter.
- Verify --path.procfs explicitly in deployment configs/Helm values.
- Smoke-test `cat $PROC_PATH/net/netstat` in entrypoint scripts before starting the exporter.
- Keep the exporter user's permissions sufficient to traverse /proc.
When it happens
Trigger: Calling NewNetStatCollector when *procPath points to a directory that does not exist, is not readable, or is not a procfs filesystem (procfs.NewFS validates the mount).
Common situations: Running node_exporter in a container without /proc mounted or mounted elsewhere; passing a wrong --path.procfs value; running on a non-Linux host or a restricted environment where /proc access is blocked.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- failed to open /proc/self
- couldn't get netstats
- failed to open procfs
- failed to open sysfs
- interrupts empty
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/e3c6d46094e84760.
Report an issue: GitHub.
Appendix: source
Thrown at collector/netstat_linux.go:61
)
type netStatCollector struct {
proc procfs.Proc
fieldPattern *regexp.Regexp
logger *slog.Logger
}
func init() {
registerCollector("netstat", defaultEnabled, NewNetStatCollector)
}
// NewNetStatCollector takes and returns
// a new Collector exposing network stats.
func NewNetStatCollector(logger *slog.Logger) (Collector, error) {
pattern := regexp.MustCompile(*netStatFields)
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
// Network statistics in /proc/net are network namespace local. Reading
// them via the current process' /proc/self/net keeps the same semantics
// while allowing the use of the procfs parsers.
proc, err := fs.Self()
if err != nil {
return nil, fmt.Errorf("failed to open /proc/self: %w", err)
}
return &netStatCollector{
proc: proc,
fieldPattern: pattern,
logger: logger,
}, nil
}
func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error {View on GitHub (pinned to 17ddd77c59)