{"record":{"id":"261656bd681d8645","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-261656","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/nfs_linux.go","lineNumber":52,"sourceCode":"\tfs                                nfs.FS\n\tnfsNetReadsDesc                   *prometheus.Desc\n\tnfsNetConnectionsDesc             *prometheus.Desc\n\tnfsRPCOperationsDesc              *prometheus.Desc\n\tnfsRPCRetransmissionsDesc         *prometheus.Desc\n\tnfsRPCAuthenticationRefreshesDesc *prometheus.Desc\n\tnfsProceduresDesc                 *prometheus.Desc\n\tlogger                            *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"nfs\", defaultEnabled, NewNfsCollector)\n}\n\n// NewNfsCollector returns a new Collector exposing NFS statistics.\nfunc NewNfsCollector(logger *slog.Logger) (Collector, error) {\n\tfs, err := nfs.NewFS(*procPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n\t}\n\n\treturn &nfsCollector{\n\t\tfs: fs,\n\t\tnfsNetReadsDesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nfsSubsystem, \"packets_total\"),\n\t\t\t\"Total NFSd network packets (sent+received) by protocol type.\",\n\t\t\t[]string{\"protocol\"},\n\t\t\tnil,\n\t\t),\n\t\tnfsNetConnectionsDesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nfsSubsystem, \"connections_total\"),\n\t\t\t\"Total number of NFSd TCP connections.\",\n\t\t\tnil,\n\t\t\tnil,\n\t\t),\n\t\tnfsRPCOperationsDesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nfsSubsystem, \"rpcs_total\"),","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/nfs_linux.go#L34-L70","documentation":"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.","triggerScenarios":"Calling NewNfsCollector when --path.procfs points to a nonexistent, unreadable, or non-procfs directory, so nfs.NewFS fails its mount validation.","commonSituations":"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.","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."],"exampleFix":"// before\nfs, err := nfs.NewFS(*procPath)\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n}\n// after (include the configured path in the error)\nfs, err := nfs.NewFS(*procPath)\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to open procfs at %q (check --path.procfs): %w\", *procPath, err)\n}","handlingStrategy":"validation","validationCode":"import \"os\"\n// Check the procfs root before constructing the collector:\nif st, err := os.Stat(*procPath); err != nil || !st.IsDir() {\n\t// fail fast: bad --path.procfs value\n}","typeGuard":"null","tryCatchPattern":"// Constructor-time fail-fast with context\nif _, err := NewNfsCollector(logger); err != nil {\n\tlogger.Error(\"NFS collector init failed; check --path.procfs\", \"err\", err)\n\tos.Exit(1)\n}","preventionTips":["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."],"tags":["linux","procfs","nfs","filesystem"],"backgroundTag":"file-open-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"}