Back to Article List

Fix the error: Hermes Telegram bot token rejected by server

Fix the error: Hermes Telegram bot token rejected by server

You set up a Telegram bot in Hermes Agent, restart the gateway and the log shows:

ERROR gateway.run: Gateway failed to connect any configured messaging platform:
telegram: Telegram startup failed: The token '8765418140:***' was rejected by the server.

First instinct is to assume the token is wrong. In my experience, 7 times out of 10 the actual cause is that you're editing the wrong config file. The token in BotFather works fine, Hermes is just loading a stale value.

Step 1: Verify the token works directly

Test the token against Telegram's API using curl. This isolates if the token is genuinely wrong or if Hermes is just sending an old one.

curl -s "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getMe"

Response with "ok": true and your bot's username: token works, Hermes is sending the wrong value.

Response with "ok": false and "description": "Unauthorized": token genuinely doesn't work. Open BotFather, run /mybots, pick the bot, choose API Token, regenerate or verify.

Step 2: Find which config Hermes is reading

Hermes can read the Telegram token from three different places:

  • ~/.hermes/.env
  • ~/.hermes/config.yaml
  • Environment variable in the shell that runs the gateway

The wizard you ran during setup wrote it to one of these. If you edited a different file later thinking you were updating the token, you weren't. The old value is still being loaded.

Check all three sources

hermes gateway config show | grep -i telegram
grep -i TELEGRAM ~/.hermes/.env 2>/dev/null
grep -i telegram ~/.hermes/config.yaml 2>/dev/null
env | grep TELEGRAM

You want exactly one source of truth. If two sources both have a token and they don't match, Hermes picks one based on load order. That might not be the one you edited.

Step 3: Update the token through the CLI

Don't hand-edit .env or config.yaml unless you know exactly where Hermes is reading from. Use the CLI which writes to the canonical location:

hermes gateway set telegram --token "8765418140:AAA..."
hermes gateway restart telegram
hermes gateway status

If status shows telegram connected, you're done. If it still says token rejected, the CLI wrote to the right location but Hermes is loading from somewhere else. Almost always means you have two Hermes installs on the same machine (one in ~/.local/bin, one elsewhere) reading conflicting configs.

which hermes
hermes --version

Clean up the stale install. See our hermes command not found piece for the cleanup pattern.

The "Unauthorized" log variant

If the log shows Unauthorized rather than "token rejected", three possible causes:

Token was revoked

Regenerate in BotFather and update Hermes through the CLI command above.

Token is correct but Hermes can't reach Telegram

Network blocked. Firewall rules. Container without outbound access.

curl -s -o /dev/null -w "%{http_code}\n" https://api.telegram.org/

200 or 401 means Telegram is reachable. Anything else (timeout, DNS error, 403): network problem, not token problem.

Whitespace in the pasted token

Leading or trailing space from a bad paste makes Telegram reject it. Re-paste through the CLI to be safe.

Bot connects but ignores your messages (allowlist issue)

The gateway connects cleanly to Telegram but the bot doesn't respond when you message it. Different problem. Bot is alive, you're just not on the allowlist.

Find your Telegram user ID

Message @userinfobot on Telegram. It tells you your numeric user ID.

Add yourself to the allowlist

hermes gateway allowlist add telegram 123456789

Open mode (testing only)

hermes gateway allowlist set telegram open

Anyone with your bot's username can now message it. Don't run open mode in production. Public bot with no allowlist racks up token costs fast.

After regenerating the token in BotFather

The old token is permanently dead. Anything with a copy needs updating:

  • ~/.hermes/.env on the box running Hermes
  • systemd unit's Environment= lines if you embedded it there
  • Docker compose file if you pass it in there
  • Any backup file you might restore from
  • Your password manager entry

Find and update everywhere:

grep -rIn "8765418140" ~/.hermes/ 2>/dev/null
sudo grep -rIn "8765418140" /etc/systemd/system/ 2>/dev/null

(Use the first part of the old token in the search, not the full token. Obvious security reasons.)

Keep the token out of version control

For production setups, don't commit the token to a config repo. Use a secrets manager (systemd-creds, sops, your cloud provider's secrets API) and have Hermes read from there. Production patterns covered in our Hermes production hardening guide.

For homelab use, an .env file outside the repo with chmod 600 is enough. Don't share it.

Where Telegram fits in a wider setup

Once Telegram works, the natural next steps:

Pre-configured Telegram on LumaDock

The Hermes Agent template on LumaDock has the gateway preinstalled with the Telegram setup wizard ready to run. Walks you through token entry, allowlist and smoke test in one flow. Unmetered bandwidth (matters when your bot is in busy channels) and no setup fees. Complete template details in our Hermes Agent complete guide.

Your idea deserves better hosting

24/7 support 30-day money-back guarantee Cancel anytime
Verrechnungszyklus

2 GB RAM VPS.S1

$5.99 Save  17 %
$4.99 Monatlich
  • 2 vCPU AMD EPYC
  • 2 GB RAMRAM
  • 30 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive

6 GB RAM VPS.S3

$14.99 Save  33 %
$9.99 Monatlich
  • 4 vCPU AMD EPYC
  • 6 GB RAMRAM
  • 70 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive

EPYC VPS.P1

$7.99 Save  25 %
$5.99 Monatlich
  • 2 vCPU AMD EPYC
  • 4 GB RAMRAM
  • 40 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

EPYC VPS.P2

$14.99 Save  27 %
$10.99 Monatlich
  • 2 vCPU AMD EPYC
  • 8 GB RAMRAM
  • 80 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

EPYC VPS.P4

$29.99 Save  20 %
$23.99 Monatlich
  • 4 vCPU AMD EPYC
  • 16 GB RAMRAM
  • 160 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

EPYC VPS.P5

$36.49 Save  21 %
$28.99 Monatlich
  • 8 vCPU AMD EPYC
  • 16 GB RAMRAM
  • 180 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

EPYC VPS.P6

$56.99 Save  21 %
$44.99 Monatlich
  • 8 vCPU AMD EPYC
  • 32 GB RAMRAM
  • 200 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

EPYC VPS.P7

$69.99 Save  20 %
$55.99 Monatlich
  • 16 vCPU AMD EPYC
  • 32 GB RAMRAM
  • 240 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

Genoa VPS.G2

$12.99 Save  23 %
$9.99 Monatlich
  • 2 vCPUAMD EPYC Genoa 4. Generation 9xx4 mit 3,25 GHz oder ähnlich, auf Zen 4-Architektur. AMD EPYC G4
  • 4 GB DDR5RAM
  • 50 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

Genoa VPS.G4

$25.99 Save  27 %
$18.99 Monatlich
  • 4 vCPUAMD EPYC Prozessor mit dedizierten vCPU Kernen, auf Enterprise Serverhardware. AMD EPYC G4
  • 8 GB DDR5RAM
  • 100 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

Genoa VPS.G6

$48.99 Save  31 %
$33.99 Monatlich
  • 8 vCPUAMD EPYC Prozessor mit dedizierten vCPU Kernen, auf Enterprise Serverhardware. AMD EPYC G4
  • 16 GB DDR5RAM
  • 200 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

Genoa VPS.G7

$74.99 Save  27 %
$54.99 Monatlich
  • 8 vCPUAMD EPYC Prozessor mit dedizierten vCPU Kernen, auf Enterprise Serverhardware. AMD EPYC G4
  • 32 GB DDR5RAM
  • 250 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden. inklusive
  • Auto-BackupEnthält einen Backup-Slot, den du auf täglich, wöchentlich oder monatlich einstellen kannst. inklusive

AMD Ryzen VPS.R1

$15.99 Save  31 %
$10.99 Monatlich
  • 1 dedizierter CPU AMD Ryzen 9 7950X mit 4,5 GHz oder ähnlich, auf Zen 4-Architektur. vCPU
  • 4 GB DDR5RAM
  • 50 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6 inklusive IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden.
  • Auto-Backup inklusive

AMD Ryzen VPS.R2

$27.99 Save  21 %
$21.99 Monatlich
  • 2 dedizierte CPUs AMD Ryzen 9 7950X mit 4,5 GHz oder ähnlich, auf Zen 4-Architektur. vCPU
  • 8 GB DDR5RAM
  • 100 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6 inklusive IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden.
  • Auto-Backup inklusive

AMD Ryzen VPS.R4

$99.99 Save  20 %
$79.99 Monatlich
  • 8 dedizierte CPUs AMD Ryzen 9 7950X mit 4,5 GHz oder ähnlich, auf Zen 4-Architektur. vCPU
  • 32 GB DDR5RAM
  • 400 GB NVMeSPEICHER
  • Unbegrenzter Traffic
  • IPv4 & IPv6 inklusive IPv6-Support ist derzeit nicht verfügbar in Frankreich, Finnland oder den Niederlanden.
  • Auto-Backup inklusive

Q & A

Why does Hermes say my Telegram bot token was rejected?

The Telegram server rejected the token Hermes sent. Either the token is wrong, you edited a config file Hermes doesn't read, or there's whitespace in the pasted value. Verify the token first with curl against api.telegram.org.

Your agent runs wild. Your bill doesn't.

Easily deploy Hermes in one click on Ubuntu 24.04 with AMD EPYC, NVMe storage and unmetered bandwidth. The price stays the same whatever the agent does, no setup fees, no overage charges and no tier traps.

GPU products are in high demand at the moment. Fill the form to get notified as soon as your preferred GPU server is back in stock.