How to Fix: “openclaw gateway install” in Linux VPS

I got this error message when execute command: openclaw gateway install

Gateway install failed: Error: systemctl --user unavailable: Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
Tip: systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.
Tip: On a headless server (SSH/no desktop session): run sudo loginctl enable-linger $(whoami) to persist your systemd user session across logins.
Tip: Also ensure XDG_RUNTIME_DIR is set: export XDG_RUNTIME_DIR=/run/user/$(id -u), then retry.
Tip: If you're in a container, run the gateway in the foreground instead of openclaw gateway.

This error occurs because OpenClaw is trying to register itself as a systemd user service, but your user session on the server doesn’t have access to DBus (usually occurs when logging in via SSH on a headless/VPS server).

Simply put: The server doesn’t know how to run OpenClaw in the background for your user because the “path” hasn’t been opened.

According to the tip in the error, here are the steps to fix it. You need to run this directly in your SSH terminal :

1. Enable “Linger” (Most Important)

This tells the server to keep your user session active even after you log out of SSH. Without it, the systemd user service won’t run.

sudo loginctl enable-linger $(whoami)

2. Set Runtime Variables

To allow the installation to communicate with systemd during the installation process, set these environment variables:

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

3. Try Installing Again

After running the two commands above, run the installation command again:

openclaw gateway install

Summary of the execution sequence in the terminal:

sudo loginctl enable-linger $(whoami)
export XDG_RUNTIME_DIR=/run/user/$(id -u)
openclaw gateway install

Why does this happen?
On modern Linux servers, services run per user (not root) are managed by systemd –user. If you log in via SSH, sometimes that user’s session doesn’t automatically create the necessary communication bus. enable-linger forces the server to always have that session available for your user.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.