Systemd collector "couldn't get dbus connection"

Hi everyone!
I’m in need for some help. :sweat_smile:

I’m trying to set up the systemd collector from node_exporter inside a docker container. I can’t figure out what the problem is.

The logs show me this, over and over again:

node_exporter  | ts=2025-07-30T13:33:46.548Z caller=collector.go:169 level=error msg="collector failed" name=systemd duration_seconds=5.5409e-05 err="couldn't get dbus connection: dial unix /var/run/dbus/system_bus_socket: connect: no such file or direct
ory"

When I exec into the container and ls the dbus dir I get this:

/ $ ls -la /host/var/run/dbus/
total 0
drwxr-xr-x    2 root     root            60 Jul 29 23:33 .
drwxr-xr-x   36 root     root           920 Jul 30 11:02 ..
srw-rw-rw-    1 root     root             0 Jul 29 23:33 system_bus_socket

So the file is present.

This is my docker-compose file:

node_exporter:
  image: quay.io/prometheus/node-exporter:v1.5.0
  container_name: node_exporter
  command:
     - "--path.rootfs=/host"
     - "--collector.systemd"
   pid: host
   restart: unless-stopped
   volumes:
      - /:/host:ro,rslave
   networks:
      - monitoring

The rest of node_exporter is working fine.

Does anyone know what I’m missing here?
Any help will be greatly appreciated!

I am retarded. It’s right there in the error log lol.
I mount my host to /host inside the container. But node_exporter is looking for /var/run/dbus/system_bus_socket, NOT /host/var/run/dbus/system_bus_socket.
Manually mounting the host’s`/var/run/dbus/system_bus_socket`to /var/run/dbus/system_bus_socket fixes my issue.

Hello,

I got the same issue, but in my system (debian 12) the folder /var/run is a link to/run so it was a broken link inside the container because there is no /run mapping to the host.

So I needed to also directly map this path as follow :

  node-exporter:
    image: prom/node-exporter:v1.9.1
    hostname: "node-exporter-{{.Node.Hostname}}"
    command:
      - '--path.rootfs=/host'
      - '--collector.systemd'
      - '--collector.processes'
    deploy:
      mode: global
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 64M
    volumes:
      - '/:/host:ro,rslave'
      - '/var/run/dbus:/var/run/dbus:ro,rslave'

I don’t know if this is only related to debian 12.

Hope this can help.