{"record":{"id":"dcb6edb8bd3117e2","repo":"prometheus/node_exporter","slug":"couldn-t-get-dbus-connection-w","errorCode":null,"errorMessage":"couldn't get dbus connection: %w","messagePattern":"couldn't get dbus connection: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/systemd_linux.go","lineNumber":186,"sourceCode":"\t\ttimerLastTriggerDesc:          timerLastTriggerDesc,\n\t\tsocketAcceptedConnectionsDesc: socketAcceptedConnectionsDesc,\n\t\tsocketCurrentConnectionsDesc:  socketCurrentConnectionsDesc,\n\t\tsocketRefusedConnectionsDesc:  socketRefusedConnectionsDesc,\n\t\tsystemdVersionDesc:            systemdVersionDesc,\n\t\tvirtualizationDesc:            virtualizationDesc,\n\t\tsystemdUnitIncludePattern:     systemdUnitIncludePattern,\n\t\tsystemdUnitExcludePattern:     systemdUnitExcludePattern,\n\t\tlogger:                        logger,\n\t}, nil\n}\n\n// Update gathers metrics from systemd.  Dbus collection is done in parallel\n// to reduce wait time for responses.\nfunc (c *systemdCollector) Update(ch chan<- prometheus.Metric) error {\n\tbegin := time.Now()\n\tconn, err := newSystemdDbusConn()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get dbus connection: %w\", err)\n\t}\n\tdefer conn.Close()\n\n\tsystemdVersion, systemdVersionFull := c.getSystemdVersion(conn)\n\tif systemdVersion < minSystemdVersionSystemState {\n\t\tc.logger.Debug(\"Detected systemd version is lower than minimum, some systemd state and timer metrics will not be available\", \"current\", systemdVersion, \"minimum\", minSystemdVersionSystemState)\n\t}\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.systemdVersionDesc,\n\t\tprometheus.GaugeValue,\n\t\tsystemdVersion,\n\t\tsystemdVersionFull,\n\t)\n\n\tsystemdVirtualization := c.getSystemdVirtualization(conn)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.virtualizationDesc,\n\t\tprometheus.GaugeValue,","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/systemd_linux.go#L168-L204","documentation":"Update calls newSystemdDbusConn to obtain a D-Bus system-bus connection to systemd; failure is wrapped as 'couldn't get dbus connection' and the whole systemd collector update aborts for this scrape. Typical causes are the D-Bus socket being absent or unreadable from the exporter's context.","triggerScenarios":"Running node_exporter where /run/systemd/private (or the system bus) does not exist, e.g. a container without systemd, or with --path.procfs/--collector.systemd enabled in an environment lacking dbus sockets.","commonSituations":"node_exporter in a Docker/Kubernetes container with no systemd; host /run not mounted; dbus-daemon not running or socket perms denying access.","solutions":["Ensure the host's /run/systemd/private is mounted into the container (e.g. -v /run/systemd/private:/run/systemd/private:ro) or run directly on the host","Disable the systemd collector if the node genuinely has no systemd: --collector.systemd is off unless enabled, so remove the enabling flag","Verify dbus/systemd is running: `systemctl is-system-running`","Check socket permissions for the exporter user"],"exampleFix":"// before (container, no systemd access)\ndocker run prom/node-exporter --collector.systemd\n// after\ndocker run -v /run/systemd/private:/run/systemd/private:ro prom/node-exporter --collector.systemd","handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(\"/run/systemd/private\"); err != nil { /* no systemd socket: skip enabling --collector.systemd */ }","typeGuard":null,"tryCatchPattern":"if err := coll.Update(ch); err != nil && strings.Contains(err.Error(), \"couldn't get dbus connection\") {\n    logger.Warn(\"systemd collector unavailable (no dbus)\", \"err\", err)\n    // fall back to other collectors\n}","preventionTips":["Only enable --collector.systemd where systemd actually runs","Mount /run/systemd/private read-only into containers that need it","Document that rootless/daemonless environments cannot export systemd metrics"],"tags":["linux","systemd","dbus","containers","network"],"backgroundTag":"connection-refused","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"}