🛠️ Real incident, fixed with AI

Recovering a Suspended Hermes Telegram Gateway

The Hermes Telegram gateway process was suspended and stopped answering; how it was identified and resumed.

In short

Hermes stopped answering in Telegram because a gateway started in a terminal was suspended, not quit. State T means the process is stopped, often by Ctrl+Z. It still held the lock, so the user service could not start a replacement. Stop the service, end that stuck process, and start the service again. It is a few commands once you have the right process id.

What you need

See the stuck process

  1. List Hermes and Telegram processes:
ps -eo pid,ppid,stat,etime,%cpu,%mem,cmd --sort=-%cpu \
  | grep -Ei '[h]ermes|[t]elegram|[b]ot'

The manual gateway looked like this:

PID 4540 ... STAT Tl ... python -m hermes_cli.main gateway run

T means stopped by job control, commonly after Ctrl+Z.

  1. Read the service log:
journalctl --user -u hermes-gateway.service -n 100 \
  --no-pager -o short-iso

You should see Gateway already running (PID 4540). and hermes-gateway.service: Failed with result 'exit-code'.

hermes gateway status looked confusing because systemd kept trying to start a new process. Telegram settings and the network were not the cause. The suspended process was doing no work, but it still owned the lock.

Stop the stuck process and start the service

  1. Find the current stale process. Do not reuse 4540 unless it is still the one listed:
ps -eo pid,ppid,sid,pgid,tpgid,tty,stat,cmd \
  | grep -E '[h]ermes.*gateway'
  1. Stop the user service so it stops fighting you:
systemctl --user stop hermes-gateway.service
  1. Ask only that process to quit. A stopped process may need CONT before it handles TERM:
kill -TERM STALE_PID
kill -CONT STALE_PID
kill -0 STALE_PID 2>/dev/null \
  && echo "still present" \
  || echo "stopped"

Warning: KILL cannot be undone. Use it only if that same process is still there after several seconds. If you stop the wrong process, start the service again in the next step.

kill -KILL STALE_PID
  1. Start Hermes through the service:
hermes gateway start
hermes gateway status
  1. Check the state file. You should see gateway_state running, active_agents 0, telegram.state connected, and telegram.error_code null:
jq '{pid,gateway_state,active_agents,platforms,updated_at}' \
  ~/.hermes/gateway_state.json
  1. Confirm polling and a fresh heartbeat:
grep -E 'polling confirmed healthy|Connected to Telegram|telegram connected' \
  ~/.hermes/logs/gateway.log | tail

stat -c '%y %n' ~/.hermes/state/gateway.heartbeat

Use these from now on:

hermes gateway status
hermes gateway restart
hermes gateway stop
hermes gateway start

Do not press Ctrl+Z on a gateway you started in the foreground. That suspends it and leaves the lock. Press Ctrl+C, then check that it exited. On this machine the user service and systemd linger were already enabled, so the managed gateway stays up after you log out of SSH.

If it doesn’t work

Official sources

This note has no separate vendor page beyond the hermes and systemctl --user commands above.

Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.

By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.