Fixing Telegram Bot 409 Conflicts and Common Python Crashes
A direct reference for diagnosing the four errors responsible for nearly all sudden Telegram bot outages.
On This Page
409 Conflict: Terminated by Other getUpdates Request
Telegram only permits a single active polling consumer per bot token. If your bot is running on a laptop terminal and you deploy the same token to the cloud at the same time, Telegram returns HTTP 409 and drops updates.
A leftover webhook from a previous host triggers the same conflict. Clear any old webhook before starting polling, and confirm only one worker instance holds the token.
# Remove any stale webhook before switching back to polling
curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook?drop_pending_updates=true"401 Unauthorized and 429 Too Many Requests
An HTTP 401 error means the token was revoked in @BotFather or copied with trailing whitespace. Run a live token probe after pasting credentials to confirm authentication immediately.
An HTTP 429 error occurs during broadcast loops that exceed Telegram per-second message limits (roughly 30 messages per second globally and 1 message per second per chat). Read retry_after from the response and sleep before retrying.
Unhandled NoneType Crashes on Media and Edited Messages
A bot that reads ctx.text without checking whether text exists will raise an exception whenever a user sends a sticker, voice note, or photo without a caption. Always guard text access cleanly.
def on_message(ctx):
text = (ctx.text or "").strip()
if not text:
return ctx.reply("Please send a text command such as /help.")
if text == "/help":
return ctx.reply("Available commands: /start, /status, /help")Fast Diagnostic Matrix for Telegram HTTP Codes
Keep this reference handy when reading crash telemetry in gravixHOST so you can pinpoint the exact root cause in under a minute.
- Root Cause
- Two polling workers or active webhook on same token
- Immediate Fix
- Stop duplicate process and call deleteWebhook
- Root Cause
- Revoked token or hidden newline/space in token
- Immediate Fix
- Regenerate in @BotFather and re-verify with getMe probe
- Root Cause
- User blocked the bot or bot kicked from group
- Immediate Fix
- Catch Forbidden per chat ID and skip without crashing
- Root Cause
- Broadcast loop exceeded Telegram burst limits
- Immediate Fix
- Honor parameters.retry_after and throttle to <=25 msg/s
Key Takeaways
- 409 Conflict always means two consumers or an old webhook are competing for one token.
- Guard against empty text fields so photos, stickers, and service events never crash your handler.
- Handle 403 Forbidden per user cleanly so one blocked chat never terminates a broadcast loop.
Host your Telegram bot 24/7 with gravixHOST
Deploy Python scripts straight from your Android phone with live BotFather probes, snapshot backups, and 30 free trial Coins.
Helpful Tools & Next Steps
