Bot hosting guide

How to Host a Telegram Bot on a VPS

Telegram bots are light. The hard part is keeping them online, deployable, and secure without overpaying for hardware.

Affiliate disclosure: some links below are affiliate links. We may earn a commission at no extra cost to you.

What a Telegram bot actually needs

Most bots are small programs that receive updates, call an API, and reply. They spend most of their time waiting, not computing. A single-core VPS with 512 MB to 1 GB RAM can comfortably run several lightweight bots.

Memory grows when you add a database, image processing, browser automation, or a local AI model. Start small and watch memory usage for a week before deciding to upgrade.

Webhook vs long polling

Long polling asks Telegram for new updates in a loop. It is simple, needs no domain, and works behind NAT. The downside is a constant request loop and slightly higher latency.

Webhook lets Telegram push updates to your HTTPS endpoint. It is more efficient and scales better, but requires a public domain, a TLS certificate, and a reverse proxy. For production bots, webhook is usually the better long-term choice.

If you are just testing, start with polling. Move to webhook when you add a domain or expect steady traffic.

How much server do you need?

SetupRAMvCPUNotes
1 simple bot256–512 MB1Polling, no database
2–5 bots1 GB1Shared process manager or Docker
Bot + database1–2 GB1–2Postgres or SQLite depending on load
Bot + browser automation2–4 GB2Playwright and Chromium are memory hungry
Bot + local LLM8 GB+4+See the GPU guide for inference

Deployment checklist

  1. Create a non-root user and disable password SSH login.
  2. Store the bot token and API keys in environment variables, not in the repository.
  3. Run the bot under systemd or Docker with a restart policy.
  4. Enable a firewall and expose only the ports you need.
  5. For webhook mode, put Nginx or Caddy in front and use TLS.
  6. Log to a file or the system journal, and add basic error alerts.
  7. Set up automatic security updates.

A systemd unit keeps the bot alive after logout and restarts it after a crash. Docker achieves the same with a restart policy and makes dependencies reproducible.

Uptime and monitoring

Telegram bots fail silently. Add a simple health endpoint or a periodic self-check that messages you when something breaks. Uptime monitors that ping an HTTP endpoint are enough for webhook bots; for polling bots, log a heartbeat and alert if it stops.

Keep an eye on memory. A slow leak will eventually crash the process, and the restart policy will hide the problem until it happens often enough to notice.

Security basics

  • Never commit tokens or API keys. Rotate them if exposed.
  • Validate and rate-limit user input to prevent abuse.
  • Run the bot with the least privileges it needs.
  • Keep the OS and dependencies patched.
  • Back up any database before upgrades.

What it costs

A single bot fits on the cheapest VPS from most providers, roughly $4–6 per month. Hetzner offers the best value if an EU region is acceptable. Vultr and DigitalOcean are convenient when you need a specific region or a familiar ecosystem.

Hetzner

2 vCPU, 4 GB RAM from about €4.5/month. Great value for multiple bots.

Check Hetzner

Vultr

Many regions and a simple API. The $5 plan is fine for one or two bots.

Check Vultr

DigitalOcean

Best documentation if you are new to servers. $6 gets a basic droplet.

Check DigitalOcean

FAQ

How much RAM does a Telegram bot need?

A simple bot runs in 128–512 MB of RAM. A 512 MB or 1 GB VPS is enough for one to three lightweight bots. Add memory if you use a database, browser automation, or machine learning.

Should I use webhook or long polling?

Webhook is more efficient and scales better because Telegram pushes updates to your server. Long polling is simpler to set up and works without a public HTTPS endpoint. For production, webhook with a reverse proxy is usually the better choice.

Do I need a domain and SSL for a bot?

Only for webhook mode. Telegram requires a public HTTPS endpoint for webhooks. A free TLS certificate from Let's Encrypt and a small reverse proxy are enough. Long polling needs neither.

How do I keep the bot running after I disconnect?

Run the bot as a systemd service or inside Docker with a restart policy. Both keep the process alive after logout and restart it automatically after crashes or reboots.

Last updated: November 2026. Always check current provider pricing and your local regulations before deploying.