Skip to main content
Jason Finance
AI Startup

How to Fix systemctl --user Failed to connect to bus: No medium found

On this page
  1. 1.What the error looks like and when it appears
  2. 2.Why systemctl –user says No medium found
  3. 3.The fix: point to the user bus from the admin account
  4. 3.1Turn on linger first and confirm the user manager is running
  5. 3.2Run it with XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS
  6. 3.3Why sudo systemctl –user doesn’t work
  7. 4.Other situations that cause this error
  8. 4.1The error becomes No such file or directory or Permission denied
  9. 4.2Already in that user’s shell: set XDG_RUNTIME_DIR
  10. 4.3Switching users with su or su -
  11. 4.4Service accounts (for example gitlab-runner)
  12. 4.5Proxmox LXC containers and WSL
  13. 4.6Two other ways from the admin account: machinectl shell and systemctl –user -M
  14. 4.7Minimal Debian installs: check dbus-user-session and pam_systemd
  15. 5.enabled, active (running) and inactive (dead): what’s the difference
  16. 6.An incomplete unit file: check it with systemd-analyze
  17. 7.How to verify the fix
  18. FAQ

On a Linux server, you switch over with sudo -iu project-user, run systemctl --user daemon-reload, and get Failed to connect to bus: No medium found. I ran into this systemctl –user No medium found error in October 2026 while turning Claude Code Remote Control into an always-on service.

The short version: this is usually not a broken systemd or a bad unit file. The shell that sudo -iu opens has no user bus for that user. The fix is to go back to an admin account with sudo rights, turn on linger, confirm the user manager is running, and then run systemctl --user through sudo -u with XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS set explicitly. Do not use sudo systemctl --user.

This post is my record of a deployment on an Oracle Cloud Ubuntu 24.04 (ARM64) server in October 2026. The commands use Ubuntu 24.04, and usernames are replaced with examples such as project-a. Other distributions or systemd versions may behave differently; the official documentation is what counts.

No user bus
Cause: the sudo -iu shell is not a full login
linger + bus
Fix: turn on linger from the admin account, run with the user bus variables
sudo systemctl --user
Don't use it: it may act on root's user manager

What the error looks like and when it appears

What I did was simple: SSH into the server with the admin account (Ubuntu’s default ubuntu), switch to the project user, and manage that user’s own systemd user service from there.

sudo -iu project-a
systemctl --user daemon-reload
# Failed to connect to bus: No medium found

This project user has no password and never logs in directly; I only reach it through sudo -iu. The full always-on Remote Control setup is in Running Claude Code Remote Control on a Free Oracle Cloud Server. This post deals only with this error.

Why systemctl –user says No medium found

systemctl --user needs to reach “this user’s own systemd user manager”, and it connects through the user D-Bus. During a normal SSH login, the login process prepares the runtime directory /run/user/<UID>/ for you and sets environment variables such as XDG_RUNTIME_DIR.

The shell that sudo -iu opens is not a full login session. Those variables may be missing, and the user bus may not exist yet. When systemctl cannot find a bus to connect to, it fails with No medium found.

If the variables are set but the directory or bus they point to does not exist, the message becomes Failed to connect to bus: No such file or directory. That variation and other environments where the error appears are covered later under “Other situations that cause this error”.

You can confirm this in that shell first:

echo "$XDG_RUNTIME_DIR"
echo "$DBUS_SESSION_BUS_ADDRESS"
ls -l "/run/user/$(id -u)/bus"

If the first two lines are empty, or the bus file does not exist, this is your situation.

The fix: point to the user bus from the admin account

Flowchart: 1 go back to an admin account with sudo rights; 2 loginctl enable-linger and confirm Linger=yes; 3 confirm user@UID.service is running; 4 run systemctl --user through sudo -u with XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS set
Ubuntu 24.04 as the example (October 2026)

Run all of the following from the admin account with sudo rights, not inside the sudo -iu shell.

Turn on linger first and confirm the user manager is running

PROJECT_USER=project-a
uid=$(id -u "$PROJECT_USER")

sudo loginctl enable-linger "$PROJECT_USER"
loginctl show-user "$PROJECT_USER" -p Linger   # expected: Linger=yes

# If /run/user/$uid/bus does not exist, check the user manager's status first
systemctl status "user@${uid}.service" --no-pager

Linger starts this user’s user manager at boot and keeps it after logout (loginctl documentation, checked on 12 October 2026). If you want the service to keep running after SSH disconnects and come back after a reboot, you need this step anyway.

Run it with XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS

sudo -u "$PROJECT_USER" \
  XDG_RUNTIME_DIR="/run/user/$uid" \
  DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
  systemctl --user daemon-reload

Typing all that every time invites mistakes, so you can wrap it in a function in the admin shell:

uctl() {
  sudo -u "$PROJECT_USER" \
    XDG_RUNTIME_DIR="/run/user/$uid" \
    DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
    systemctl --user "$@"
}

uctl daemon-reload
uctl enable --now claude-project-a.service
uctl status claude-project-a.service --no-pager -l

Reading the logs works the same way:

sudo -u "$PROJECT_USER" \
  XDG_RUNTIME_DIR="/run/user/$uid" \
  DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
  journalctl --user -u claude-project-a.service -n 80 --no-pager

Why sudo systemctl –user doesn’t work

sudo systemctl --user ... looks like “managing a user service with sudo rights”, but by default sudo may switch to root, so you are talking to root’s user manager, not project-a’s. You may reload the wrong target, fail to find the service, or see an unrelated status.

To manage a user’s user service, run as that user (sudo -u project-a) and point to that user’s bus.

Other situations that cause this error

What I hit was sudo -iu, but the same error shows up in other setups too, and the cause is mostly the same: the shell running systemctl --user doesn’t know where that user’s runtime directory is, or that directory or bus doesn’t exist at all. Results marked “tested” in this section were run on 16 November 2026 on the same Ubuntu 24.04 (systemd 255) server, from an ordinary account without sudo rights. Anything that needs sudo, or a tool this server doesn’t have installed, names the official documentation it is based on.

The error becomes No such file or directory or Permission denied

First reproduce the original error by removing both variables before running it:

env -u XDG_RUNTIME_DIR -u DBUS_SESSION_BUS_ADDRESS systemctl --user status
# Failed to connect to bus: No medium found

Then point the variables at different places, and the error message changes with them (tested):

Variable state Error message
Neither XDG_RUNTIME_DIR nor DBUS_SESSION_BUS_ADDRESS is set No medium found
XDG_RUNTIME_DIR points to a directory that doesn’t exist No such file or directory
DBUS_SESSION_BUS_ADDRESS points to a bus that doesn’t exist No such file or directory
XDG_RUNTIME_DIR points to a directory you have no permission to enter Permission denied

No such file or directory means the variables are set but nothing is at the place they point to. One possible reason is that the user has no active login session and linger is off, so /run/user/<UID> has not been created yet. According to the pam_systemd documentation (checked on 16 November 2026), this directory is created the first time the user logs in and removed at the user’s final logout. Check whether it exists with ls -ld /run/user/<UID> first; if it doesn’t, go back to the linger step above.

Already in that user’s shell: set XDG_RUNTIME_DIR

If you have already switched to the user with sudo -iu and /run/user/<UID> exists (for example, linger is already on), you can also set the variable directly in that shell:

export XDG_RUNTIME_DIR="/run/user/$(id -u)"
systemctl --user status

In my test, setting only XDG_RUNTIME_DIR without DBUS_SESSION_BUS_ADDRESS was enough for both systemctl --user and busctl --user to connect; busctl looks for the bus at $XDG_RUNTIME_DIR/bus on its own.

Switching users with su or su -

According to the su manual page, su project-a (without -l) sets only HOME and SHELL, plus USER and LOGNAME when the target is not root, and carries the rest of the environment over unchanged. So XDG_RUNTIME_DIR may still point to the previous user’s /run/user/<UID>. On this server, every directory ls -ld /run/user/* lists is drwx------, which only its owner can enter, so what you see then may be the Permission denied from the table rather than No medium found.

su - (the same as su -l) clears the environment variables, but the pam_systemd documentation states that XDG_RUNTIME_DIR is not set if the current user is not the original user of the session. Running su - from your own SSH session into another account is exactly that case, so most likely neither variable is set and the result is the same No medium found as with sudo -iu. Switching to su - won’t fix it. Handle it the same way as above: pass the variables from the admin account, or use machinectl shell or systemctl --user -M, covered below.

Service accounts (for example gitlab-runner)

Service accounts such as gitlab-runner usually never log in interactively, and if linger is also off, /run/user/<UID> does not exist. The system account nobody on this server is like that (tested):

ls -ld "/run/user/$(id -u nobody)"
# ls: cannot access '/run/user/65534': No such file or directory

You have two options here. If you are sure you want to manage it as a user service, follow the fix above: turn on linger for the account first, then run the commands from the admin account with the variables. If it is just a background program that should start at boot, you can also write it as a system service and set the account it runs as with User= in the unit’s [Service] section (systemd.exec documentation), then manage it with sudo systemctl. No user bus is needed.

Proxmox LXC containers and WSL

I have not tested either environment.

Inside an LXC container the checks are the same as on the host, but first confirm that the container’s PID 1 is systemd; otherwise systemctl --user has no user manager to connect to. This is what the command returns on this server (tested):

ps -p 1 -o comm=
# systemd

Once PID 1 is systemd, follow the steps above: confirm /run/user/<UID> exists and pass the variables, or use machinectl shell or systemctl --user -M below.

For WSL, according to Microsoft’s WSL systemd documentation (checked on 16 November 2026), the current version of Ubuntu installed by default with wsl --install already uses systemd; other distributions need the two lines below in /etc/wsl.conf, followed by a restart with wsl.exe --shutdown. Without systemd, there is no user manager to connect to. The same document also notes that systemd services will not keep your WSL instance alive, so factor that in if you want an always-on service.

[boot]
systemd=true

Two other ways from the admin account: machinectl shell and systemctl –user -M

The fix above passes the two variables by hand. systemd has two other ways to get a similar result. Both need sudo, so I could not fully test them on this server; the following is based on the official documentation (checked on 16 November 2026):

  • sudo machinectl shell project-a@: according to the machinectl documentation, it connects to the local host when no container name is given, and prefixing the name with “user@” selects the user. It is similar to su, but opens a completely separate new session that does not inherit the original environment variables. On Ubuntu 24.04, machinectl is in the systemd-container package, which this server does not have installed. If the account’s default shell is nologin, you can name the program to run after it, for example sudo machinectl shell gitlab-runner@ /bin/bash.
  • sudo systemctl --user -M project-a@ status: the -M entry in the systemctl documentation states that --user with “user@.host” connects to that specific user’s user bus, and that leaving out .host means the local host. According to the systemd release notes, this usage is supported from systemd 248; check your version with systemctl --version (this server runs 255). Unlike the sudo systemctl --user I advised against above, -M says explicitly which user to connect to.

I could only test -M against my own account: with both variables set, systemctl --user -M <your own account>@ works; with the variables removed, the same command also fails with No medium found. So using -M on yourself inside a sudo -iu shell doesn’t help; use it from the admin account against another account.

Minimal Debian installs: check dbus-user-session and pam_systemd

The /run/user/<UID>/bus in the fix above is created by dbus.socket, a user unit from the dbus-user-session package. This Ubuntu 24.04 server has the package installed, and you can see where it listens; %t is the user’s runtime directory (tested):

systemctl --user cat dbus.socket
# ListenStream=%t/bus

I also tested with a runtime directory that held only the user manager’s own socket (systemd/private) and no bus: systemctl --user still connected, while busctl --user failed with No such file or directory. In other words, without bus, the DBUS_SESSION_BUS_ADDRESS in the fix above points to a file that doesn’t exist, and other tools that use the user D-Bus fail too.

A minimal Debian install may not have this package. The other thing to check is pam_systemd, which registers the session with systemd-logind at login. According to the Debian package page, dbus-user-session depends on libpam-systemd, which provides this module. To check:

dpkg -l dbus-user-session libpam-systemd
grep -r pam_systemd /etc/pam.d/
ls -l "/run/user/$(id -u)/bus"

On this Ubuntu 24.04 server, both packages show ii (installed), and pam_systemd appears in /etc/pam.d/common-session. If a package is missing, install it from an account with sudo rights with sudo apt install dbus-user-session (I did not run this step on this server).

enabled, active (running) and inactive (dead): what’s the difference

Once the bus is connected, the next common mistake is assuming enabled means the service is running. That happened to me: one Remote Control service showed Loaded: ... enabled but Active: inactive (dead) (Result: exit-code), while another service at the same time was active (running), and I had already confirmed Linger=yes.

State Meaning What to do
enabled systemd will try to start it when its start conditions are met (for example, when the user manager starts) It only means “set to start”, not that it is running now
active (running) The process really exists right now Still check the logs and actual behavior; a running process does not mean it works
inactive (dead) Not running at the moment; it may have been stopped by hand or exited after starting Read Result: and the logs before deciding whether to start
activating (auto-restart) systemd is retrying according to the Restart= setting Usually means it keeps failing; read the logs and don’t keep restarting it by hand
Linger=yes The user’s processes do not depend on an interactive login Does not guarantee the application itself starts successfully

Check whether it is enabled and what state it is in:

uctl is-enabled claude-project-a.service
uctl status claude-project-a.service --no-pager -l
uctl --failed --no-pager

Only start it directly when you are sure the service was stopped on purpose and there is no unresolved startup error. If you see status=1/FAILURE, read the journal first. For the exit code 1 I saw that time, I don’t have enough logs to confirm the root cause, so I won’t claim one here. For the troubleshooting order when a service keeps failing to start, see Running Multiple Claude Code Remote Controls on One Server.

An incomplete unit file: check it with systemd-analyze

Another case I actually hit: I wrote a unit file with a shell heredoc (cat > file <<'EOF' ... EOF), the end marker was not closed properly, and the file was missing its final [Install] section. The result can be a failing systemctl enable, or a service you think is set up while the file is actually incomplete.

After writing a unit, check it before you reload:

tail -n 12 ~/.config/systemd/user/claude-project-a.service
systemd-analyze --user verify ~/.config/systemd/user/claude-project-a.service

A complete user service should end with:

[Install]
WantedBy=default.target

Without an [Install] section, enable does not know which target to attach the service to. If systemd-analyze --user also cannot run because of the user bus, have the admin check the file contents and then daemon-reload the way shown above. When fixing files, touch only the one with the problem; don’t overwrite other services that are working fine while you’re at it.

How to verify the fix

  1. loginctl show-user project-a -p Linger returns Linger=yes.
  2. uctl is-enabled returns enabled, and uctl status shows active (running).
  3. The logs show the process starting normally (for Claude Code Remote Control, Connected and the environment name).
  4. Close SSH completely, reconnect, and the service is still running.
  5. Pick a time when nothing important is running, reboot, and confirm the service comes back on its own.

active (running) only proves the process exists. Whether Remote Control is actually connected is something you check in the logs and in the environment list on your phone or the web. The full always-on setup is in Running Claude Code Remote Control on a Free Oracle Cloud Server; for the tools behind the whole site, see Jason Finance from Zero to One.

FAQ

Why does systemctl --user say No medium found?

It usually happens when you run it after switching to another user with sudo -iu. That shell is not a full login, so XDG_RUNTIME_DIR and the user D-Bus address may not be set, and systemctl cannot find that user's user manager. It does not mean systemd is broken or that the unit file is wrong.

How do I fix systemctl --user No medium found?

Go back to an admin account with sudo rights. Turn on linger for the user with loginctl enable-linger, confirm that user@UID.service is running, then run systemctl --user through sudo -u with XDG_RUNTIME_DIR=/run/user/UID and DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/UID/bus.

Can I just use sudo systemctl --user?

Not recommended. By default sudo may switch to root, so you would be talking to root's user manager rather than the project user's, and you end up changing the wrong thing or reading the wrong status.

The service shows enabled. Why isn't it running?

enabled only means systemd will try to start it when its start conditions are met; active (running) is what tells you the process exists right now. A service that was stopped by hand or failed to start can still be enabled while its state is inactive (dead).

What does activating (auto-restart) mean?

systemd is restarting the service according to its Restart setting, which usually means it keeps failing to start. Read the journalctl logs first instead of restarting it by hand over and over.

How do I check that a unit file is complete?

Look at the end of the file with tail, then check it with systemd-analyze --user verify. If the [Install] section is missing, systemctl enable may fail, or you may think the service is set up when the file is actually incomplete.

Is Failed to connect to bus: No such file or directory the same problem as No medium found?

It is the same kind of problem. In my tests on Ubuntu 24.04 (systemd 255), the error was No medium found when neither XDG_RUNTIME_DIR nor DBUS_SESSION_BUS_ADDRESS was set, and No such file or directory when the variables were set but the directory or bus they pointed to did not exist. First confirm that /run/user/UID exists (linger is on or there is an active login session); on a minimal Debian install, also confirm that dbus-user-session is installed.

Related articles

About the author

Photo of Jason

Jason

Account Manager in Google Large Customer Sales and Columbia MBA admit, sharing the money tools and experience he actually uses.

Comments

Sign in with Google to comment. Your comment will not show your Google profile picture or name; it appears under a randomly generated nickname to protect your privacy.

By signing in you agree to this site's privacy policy.

  1. Loading comments…