Skip to content

[Bug]: hermes-gateway does not start automatically if installed as user #43748

Closed as not planned

Description

@FlorinAndrei

Bug Description

(There seem to be recent fixes related to this issue, but I believe this issue is distinct.)

Installed Hermes as a user (not root) on Ubuntu 24.04 Server (default OS install options).

I always ssh into the machine as a different user, and then to run commands as the hermes user I do this:

$ sudo su - hermes

The hermes-gateway service was installed to start as a user (not root). It seemed to work well, but after a reboot, the service would not start. Checking the status as the user hermes:

$ systemctl --user status hermes-gateway
Failed to connect to bus: No medium found

Steps to Reproduce

Install Hermes on Ubuntu 24.04 Server, as a user. Configure hermes-gateway to start via systemd as a user.

Expected Behavior

hermes-gateway should start automatically after a reboot.

Actual Behavior

hermes-gateway does not start

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Slack

Debug Report

Report       https://paste.rs/OE8zc
  agent.log    https://paste.rs/xsAc1
  gateway.log  https://paste.rs/lS44z

Operating System

Ubuntu 24.04

Python Version

3.11.15

Hermes Version

Hermes Agent v0.16.0 (2026.6.5) · upstream 6110aed

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

This is what fixed it.

As root:

# loginctl enable-linger hermes

As the hermes user:

$ systemctl --user enable --now hermes-gateway

(the --now part seems important)

And then to allow systemctl to work normally from the hermes user, I put this in ~/.profile:

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

And now hermes-gateway starts automatically after reboot, and systemctl works well as a user.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Activity

  1. added
    type/bugSomething isn't working
    comp/gatewayGateway runner, session dispatch, delivery
    area/configConfig system, migrations, profiles
    P2Medium — degraded but workaround exists
    on Jun 10, 2026
  2. FlorinAndrei commented on Jun 23, 2026

    @FlorinAndrei
    Author

    Instead of exporting variables (export XDG_RUNTIME_DIR="/run/user/$(id -u)") you could use machinectl to switch to the agent user account instead of sudo su - USER:

    sudo machinectl shell USER@
    

    After that, running systemctl as the agent user seems fine.

    I still did this as root, beforehand:

    loginctl enable-linger USER
    

    And I still did this as the agent user, after the Hermes installer ran:

    systemctl --user enable --now hermes-gateway
    

    This is on Ubuntu 26.04 with Hermes 0.17.0

  3. teknium1 commented on Jul 14, 2026

    @teknium1
    Collaborator

    Thanks for documenting the reproduction and the loginctl/user-service workaround. This is now covered on current main. Automated hermes-sweeper review found:

    • hermes_cli/gateway.py:3206 invokes _ensure_linger_enabled() after installing a user systemd unit; it attempts loginctl enable-linger and prints the required sudo command if authorization is unavailable.
    • hermes_cli/gateway.py:1853 restores XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS from /run/user/<uid> before user-scope systemctl calls, specifically addressing Failed to connect to bus: No medium found.
    • tests/hermes_cli/test_gateway_linger.py:40 and :101 cover both linger enablement and its installation-path invocation.
    • The headless-VM guidance is documented at website/docs/user-guide/messaging/index.md:462.

    Implemented by f10e26f731ece83e750ccfec86f46753e918e827 and subsequent headless user-D-Bus handling in 60e38e82eca9c68e831506eeecf1b348699302cc.

  4. added a commit that references this issue on Aug 5, 2026
  5. added a commit that references this issue on Aug 11, 2026
  6. added a commit that references this issue on Aug 12, 2026
  7. added a commit that references this issue on Aug 26, 2026
  8. added a commit that references this issue on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/gatewayGateway runner, session dispatch, deliverysweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions