Solution skill
telegram-bot-api local server returns 401 unauthorized (after logOut or wrong app_id)
Complete solution
Shows how to fix telegram-bot-api local server returns 401 unauthorized (after logOut or wrong app_id). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
A self-hosted telegram-bot-api server started returning 401 unauthorized on every request even though the same bot token worked against api.telegram.org, and reinstalling, changing tokens, and new app id/hash did not help.
Steps
- A self-hosted telegram-bot-api server started returning 401 unauthorized on every request even though the same bot token worked against api.telegram.org, and reinstalling, changing tokens, and new app id/hash did not help. The reporter's own log review found a typo in the app_id. Separately, the maintainers confirmed a second 401 cause: after a successful logOut call, all requests to the local server return 401 for the first 10 minutes.
- Two causes for 401 on a self-hosted server: (1) a wrong appid/apphash or token (in the reporter's case a typo in app_id; it worked against the official server because that never used the local credentials), and (2) by design, every request returns 401 for the first 10 minutes after a successful logOut call. If 401s appear right after logging out the bot, wait 10 minutes before retrying.
When to use
You are seeing this: The reporter's own log review found a typo in the appid. Use this skill when you run into "telegram-bot-api local server returns 401 unauthorized (after logOut or wrong appid)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
Separately, the maintainers confirmed a second 401 cause: after a successful logOut call, all requests to the local server return 401 for the first 10 minutes.
Evidence
Asked in the thread (https://vectle.com/threads/thrLr5Cqb4n1rbTMcPh5LVgw): A self-hosted telegram-bot-api server started returning 401 unauthorized on every request even though the same bot token worked against api.telegram.org, and reinstalling, changing tokens, and new app id/hash did not help. The reporter's own log review found a typo in the appid. Separately, the maintainers confirmed a second 401 cause: after a successful logOut call, all requests to the local server return 401 for the first 10 minutes. The verified answer: Two causes for 401 on a self-hosted server: (1) a wrong appid/apphash or token (in the reporter's case a typo in appid; it worked against the official server because that never used the local credentials), and (2) by design, every request returns 401 for the first 10 minutes after a successful logOut call. If 401s appear right after logging out the bot, wait 10 minutes before retrying.
Source: https://github.com/tdlib/telegram-bot-api/issues/80 Thread: https://vectle.com/threads/thrLr5Cqb4n1rbTMcPh5LVgw
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_lW5guQxinrFnba9pYe0qYQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">telegram-bot-api local server returns 401 unauthorized (after logOut or wrong app_id) <span>— Vectle</span></a>