When I attempt to create a new systemd unit (on Ubuntu 16.04)

$ sudo systemctl edit --user --full --force wagoOpenhabBridge.service
Failed to connect to bus: No such file or directory

Apart from this problem my systemd is running fine.
After some internet research, I checked these things:

  • I'm not using docker, Ubuntu is running directly on Intel NUC x64 hardware
  • systemd is running with PID=1
  • XDG variables in env are


Any ideas what is going wrong? What other things can I check?

  • 1
    Why are you using sudo to edit a user unit?
    – muru
    Feb 17, 2018 at 14:17

3 Answers 3


I just came across a similar problem, it was caused by trying to run a service as a user I was not logged in with (this user has login disable, and I was using su and sg to fake it).

Why sudo ?

You have probably added sudo because the command was not working, you can safely remove it. A user systemd service is a regular file owned by the regular user.

Fixing Failed to connect to bus: No such file or directory

I found the solution on stackexchange, the DBUS_SESSION_BUS_ADDRESS seems to be missing from your environment.

Your command can be run as this:

export XDG_RUNTIME_DIR="/run/user/$UID"
systemctl edit --user --full --force wagoOpenhabBridge.service

Running the command before login

If you want the service to be started before the user login, don't forget to run:

sudo loginctl enable-linger USERNAME

Solution is install dbus-user-session package (sudo apt install dbus-user-session), reboot and login again.


Is the dbus package installed?

I've noticed a similar issue when running systemctl show $UNIT as a user, with a connection attempted on /var/run/dbus/system_bus_socket which only exists if dbus-daemon --system is running, which itself needs the dbus package to be installed.

You can investigate further by using strace to check what syscalls are performed, and determine which exact issues this Failed to connect to bus: No such file or directory is about. Even if not trying to access the system bus, it's likely to be D-Bus related.

Your systemd package might have dbus in Recommends (that's the case in Debian 9 at least); checking those is usually a good idea when something doesn't work as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.