prometheus/node_exporter · error
failed to open procfs
Error message
failed to open procfs: %w
What it means
NewNfsCollector initializes the NFS collector by opening the procfs filesystem via nfs.NewFS(*procPath), which validates that the path is a mounted procfs. If the path cannot be opened as procfs, the constructor returns this wrapped error and the NFS collector is not registered.
Solutions
- Ensure /proc is mounted and the --path.procfs flag points to the correct procfs root (default /proc).
- In containers, bind-mount /proc read-only (e.g. -v /proc:/host/proc:ro with --path.procfs=/host/proc).
- Check read permissions for the exporter user on the procfs path.
- If NFS stats aren't needed, disable the collector instead of fixing the path.
Example fix
// before
fs, err := nfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
// after (include the configured path in the error)
fs, err := nfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs at %q (check --path.procfs): %w", *procPath, err)
} Defensive patterns
Strategy: validation
Validate before calling
import "os"
// Check the procfs root before constructing the collector:
if st, err := os.Stat(*procPath); err != nil || !st.IsDir() {
// fail fast: bad --path.procfs value
} Type guard
null
Try / catch
// Constructor-time fail-fast with context
if _, err := NewNfsCollector(logger); err != nil {
logger.Error("NFS collector init failed; check --path.procfs", "err", err)
os.Exit(1)
} Prevention
- Mount /proc into containers (read-only) and set --path.procfs accordingly.
- Validate the procfs path in startup scripts/entrypoints before launching the exporter.
- Keep the flag value consistent across collector configurations in your deployment tooling.
- Disable the NFS collector on hosts where NFS stats are not relevant.
When it happens
Trigger: Calling NewNfsCollector when --path.procfs points to a nonexistent, unreadable, or non-procfs directory, so nfs.NewFS fails its mount validation.
Common situations: Wrong --path.procfs flag value; running in containers without /proc mounted at the expected location; running node_exporter on hosts where NFS-related procfs files are absent.
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 procfs
- failed to open procfs
- failed to open /proc/self
- failed to retrieve nfs stats
- failed to open sysfs
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/261656bd681d8645.
Report an issue: GitHub.
Appendix: source
Thrown at collector/nfs_linux.go:52
fs nfs.FS
nfsNetReadsDesc *prometheus.Desc
nfsNetConnectionsDesc *prometheus.Desc
nfsRPCOperationsDesc *prometheus.Desc
nfsRPCRetransmissionsDesc *prometheus.Desc
nfsRPCAuthenticationRefreshesDesc *prometheus.Desc
nfsProceduresDesc *prometheus.Desc
logger *slog.Logger
}
func init() {
registerCollector("nfs", defaultEnabled, NewNfsCollector)
}
// NewNfsCollector returns a new Collector exposing NFS statistics.
func NewNfsCollector(logger *slog.Logger) (Collector, error) {
fs, err := nfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
return &nfsCollector{
fs: fs,
nfsNetReadsDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, nfsSubsystem, "packets_total"),
"Total NFSd network packets (sent+received) by protocol type.",
[]string{"protocol"},
nil,
),
nfsNetConnectionsDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, nfsSubsystem, "connections_total"),
"Total number of NFSd TCP connections.",
nil,
nil,
),
nfsRPCOperationsDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, nfsSubsystem, "rpcs_total"),View on GitHub (pinned to 17ddd77c59)