prometheus/node_exporter · error

couldn't get dbus connection

Error message

couldn't get dbus connection: %w

What it means

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.

Solutions

  1. 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
  2. Disable the systemd collector if the node genuinely has no systemd: --collector.systemd is off unless enabled, so remove the enabling flag
  3. Verify dbus/systemd is running: `systemctl is-system-running`
  4. Check socket permissions for the exporter user

Example fix

// before (container, no systemd access)
docker run prom/node-exporter --collector.systemd
// after
docker run -v /run/systemd/private:/run/systemd/private:ro prom/node-exporter --collector.systemd
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := os.Stat("/run/systemd/private"); err != nil { /* no systemd socket: skip enabling --collector.systemd */ }

Try / catch

if err := coll.Update(ch); err != nil && strings.Contains(err.Error(), "couldn't get dbus connection") {
    logger.Warn("systemd collector unavailable (no dbus)", "err", err)
    // fall back to other collectors
}

Prevention

When it happens

Trigger: 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.

Common situations: node_exporter in a Docker/Kubernetes container with no systemd; host /run not mounted; dbus-daemon not running or socket perms denying access.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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

Appendix: source

Thrown at collector/systemd_linux.go:186

		timerLastTriggerDesc:          timerLastTriggerDesc,
		socketAcceptedConnectionsDesc: socketAcceptedConnectionsDesc,
		socketCurrentConnectionsDesc:  socketCurrentConnectionsDesc,
		socketRefusedConnectionsDesc:  socketRefusedConnectionsDesc,
		systemdVersionDesc:            systemdVersionDesc,
		virtualizationDesc:            virtualizationDesc,
		systemdUnitIncludePattern:     systemdUnitIncludePattern,
		systemdUnitExcludePattern:     systemdUnitExcludePattern,
		logger:                        logger,
	}, nil
}

// Update gathers metrics from systemd.  Dbus collection is done in parallel
// to reduce wait time for responses.
func (c *systemdCollector) Update(ch chan<- prometheus.Metric) error {
	begin := time.Now()
	conn, err := newSystemdDbusConn()
	if err != nil {
		return fmt.Errorf("couldn't get dbus connection: %w", err)
	}
	defer conn.Close()

	systemdVersion, systemdVersionFull := c.getSystemdVersion(conn)
	if systemdVersion < minSystemdVersionSystemState {
		c.logger.Debug("Detected systemd version is lower than minimum, some systemd state and timer metrics will not be available", "current", systemdVersion, "minimum", minSystemdVersionSystemState)
	}
	ch <- prometheus.MustNewConstMetric(
		c.systemdVersionDesc,
		prometheus.GaugeValue,
		systemdVersion,
		systemdVersionFull,
	)

	systemdVirtualization := c.getSystemdVirtualization(conn)
	ch <- prometheus.MustNewConstMetric(
		c.virtualizationDesc,
		prometheus.GaugeValue,

View on GitHub (pinned to 17ddd77c59)