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
- A shell on the Hermes machine
systemctl --userforhermes-gateway.service- The live process id. The id in the notes below, 4540, is the one from this incident. Do not type it unless
psstill shows that same process.
See the stuck process
- 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.
- 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
- 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'
- Stop the user service so it stops fighting you:
systemctl --user stop hermes-gateway.service
- Ask only that process to quit. A stopped process may need
CONTbefore it handlesTERM:
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
- Start Hermes through the service:
hermes gateway start
hermes gateway status
- Check the state file. You should see
gateway_staterunning,active_agents0,telegram.stateconnected, andtelegram.error_codenull:
jq '{pid,gateway_state,active_agents,platforms,updated_at}' \
~/.hermes/gateway_state.json
- 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
psshows stateTagain. Someone suspended a manual gateway. Repeat the stop,TERM,CONTsequence on the new id.- The service log still says the gateway is already running. The old process is still alive. Do not start a second copy until
kill -0says it is gone. - Telegram stays disconnected and the heartbeat time is not moving. This is a different problem than a suspended process. See the network-timeout note before you restart in a loop.
- You stopped the service and want it back before you touch a process. Run
hermes gateway start. - You were about to type 4540 from this page. Run
psfirst and use the id it prints.
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.