Getting a Telegram bot to answer on your laptop takes ten minutes. Keeping it answering for months is a different job. These are the five problems I see most often when a bot moves from python bot.py to a server. None of them is specific to any host.
1. Polling or webhook: pick one, and know what it needs
Telegram gives a bot its updates in one of two ways, and never both at once.
- Polling (
getUpdates): your bot asks Telegram for new messages in a loop. It needs no public address, but the process must never stop. A platform that puts idle processes to sleep will silently stop your bot. - Webhook: Telegram sends each update to your HTTPS address. Only ports 443, 80, 88 and 8443 are allowed, and the address needs a valid certificate. Your code only has to answer HTTP requests, so it can scale down between messages.
Start with polling. Move to a webhook when you have a reason: many users, serverless hosting, or not wanting a loop running all day.
2. 409 Conflict: terminated by other getUpdates request
This one confuses everybody the first time. It means two copies of your bot are polling with the same token. The usual culprits:
- the bot is still running on your laptop while the server copy starts;
- a deploy starts the new version before the old one has stopped;
- a webhook is still set, and you started polling.
Fix: run exactly one poller per token. If you switched from webhook to polling, call deleteWebhook once. Use a separate test bot from BotFather for local development, so your laptop never fights production.
3. 429 Too Many Requests: retry after N
Telegram limits how fast a bot can send: roughly one message per second per chat, about 20 per minute in a group, and about 30 per second overall for broadcasts. Go over the limit and you get 429 with a retry_after value.
Do not retry in a tight loop. Read retry_after, sleep that long, then send again. For broadcasts, queue the messages and send at a steady rate. aiogram, python-telegram-bot and grammY all have helpers or middleware for this.
4. The bot "forgets" everything after a restart
If you keep state in a dict or in a SQLite file next to your code, it disappears on every deploy on most platforms, because the container is rebuilt from the image.
- For small state, write to a volume that survives restarts.
- For anything that matters (orders, payments, user settings), use a real database such as PostgreSQL, with backups.
- Never keep the bot token in the repository. Put it in an environment variable such as
BOT_TOKEN.
5. It crashed at 3 a.m. and nobody noticed
A bot that dies quietly is worse than a bot that never started. You want three things:
- Automatic restart when the process exits.
- A limit: if it crashes over and over, stop restarting and tell a human, because a crash loop can also burn through rate limits.
- An alert where you already are. For a Telegram bot, that is Telegram.
Log the last error line before exit. "Process exited with code 1" tells you nothing at 3 a.m.
A note on where the server is
If your users are in Central Asia, the nearest region most hosting platforms offer is in Europe, and most of them ask for an international card. That is fine for many teams, and a VPS with systemd is still a perfectly good option if you like looking after a server.
I work on Livops, a platform with servers in Tashkent that runs Telegram bots from a GitHub repo or a Docker image. Polling and webhook both work. A crashed bot is restarted, and if it keeps failing it is stopped and you are told in the cabinet (and in Telegram, if you link your account). You pay in Uzbek so'm through Payme or Click, without a card. A bot costs 19 credits a month (19,000 so'm). Use whatever fits you. The five problems above are the same everywhere.
Disclosure: I work on Livops. This post was drafted with AI assistance and checked against the Telegram Bot API docs and the Livops docs.
