How to Host a Telegram Bot 24/7 on a VPS in 2026

A Telegram bot that only works while your laptop is open is a demo. A bot your customers or community rely on needs to run around the clock, restart itself after a crash, and keep working through updates. The good news is that bots are light: a small VPS can run several of them comfortably. This guide covers how to choose the server, run your bot as a proper service, decide between polling and webhooks, and keep it healthy.
What resources does a Telegram bot need?
Most bots spend their time waiting for messages, so they use very little CPU. Memory depends on your language and libraries. As a rough guide:
One to five simple bots written in Python or Node.js: 1 to 2 vCPU and 1 to 2 GB RAM.
Bots that process media, call AI APIs or store data in a database: 2 vCPU and 4 GB RAM, plus fast NVMe storage for the database.
A Telegram channel with automation around it, such as scheduled posts or moderation: the same small server is enough; reliability matters far more than raw power.
Location matters a little: Telegram's infrastructure is concentrated in Europe and the US, so a VPS in either region keeps API round trips short. IM HOST Linux VPS plans are available in the US, UK, Poland, Germany and Egypt.
Step 1: Run the bot as a service, not in a terminal
The most common reason bots die is that they were started in an SSH session or screen window and nobody noticed when they crashed. On Linux, run the bot under systemd so the operating system starts it at boot and restarts it automatically:
[Unit]
Description=Telegram bot
After=network-online.target
Wants=network-online.target
[Service]
User=bot
WorkingDirectory=/opt/mybot
EnvironmentFile=/opt/mybot/.env
ExecStart=/opt/mybot/venv/bin/python bot.py
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.targetSave it as /etc/systemd/system/mybot.service, then run systemctl daemon-reload and systemctl enable --now mybot. With Restart=always, a crash becomes a three-second pause instead of an outage. Logs are available with journalctl -u mybot -f.
If you prefer containers, Docker with restart: unless-stopped achieves the same result.
Step 2: Keep the token out of your code
Your bot token is a password. Store it in an environment file readable only by the bot user, never in the source code and never in a public repository. If a token leaks, revoke it immediately from BotFather and issue a new one.
Step 3: Choose long polling or webhooks
Long polling
Your bot repeatedly asks Telegram for new updates. It is the simplest option: no domain, no certificate and no open inbound ports. It is the right choice for most single-server bots.
Webhooks
Telegram pushes each update to an HTTPS URL on your server. It is more efficient at scale and reacts instantly, but it needs a domain, a valid TLS certificate and a reverse proxy such as Caddy or Nginx in front of the bot. Choose webhooks when you run many bots, handle high message volume or already operate a web server.
Use one method per bot. Mixing them for the same token causes updates to be missed.
Step 4: Respect Telegram's rate limits
Telegram limits how fast bots can send messages, especially in bulk and to groups. If you broadcast to many users, queue messages and send them at a controlled rate, handle "Too Many Requests" responses by waiting the time Telegram tells you, and avoid bursts. A bot that floods the API can be temporarily blocked.
Step 5: Monitor the bot, not just the server
Health pings: have the bot call an external heartbeat service every few minutes, so you get an alert when it stops responding even though the server is up.
Log rotation: a bot that logs every update can fill a small disk in weeks. Set limits on journald or your log files.
Alerts on restarts: frequent automatic restarts usually point to a bug or a memory leak.
Step 6: Back up what matters
If your bot stores users, orders, subscriptions or settings, back up its database daily and keep copies off the server. Keep a copy of your configuration and environment files too, stored securely.
A minimal hardening list
SSH keys only, password login disabled.
A dedicated non-root user for the bot.
A firewall that allows only SSH, plus 443 if you use webhooks.
Automatic security updates for the operating system.
Run your bots on IM HOST
An entry-level Linux VPS from IM HOST is enough for several bots, with full root access, a 10 Gbit network port, a dedicated IPv4 plus a /64 IPv6, and support from engineers 24/7. If your bot also runs heavier jobs, a Cloud VPS adds fully dedicated vCPU and RAM and a free automatic backup every 72 hours.
More from our blog
Discover more practical guides and product insights from the IM Host team.
View all articles