Tutorials5 min read

How to Host a Telegram Bot on a BDIX VPS (24/7 Uptime Guide)

S

SNBD Host Team

July 13, 2026

If you've built a Telegram bot in Python or Node.js and you're running it on your laptop, you already know the problem: the moment you close your computer, the bot goes offline. Customers message it, get no response, and you lose the interaction.

The solution is to run the bot on a VPS — a server that stays on 24/7. This guide walks through deploying a Telegram bot on a BDIX VPS from SNBD HOST, with proper process management so it restarts automatically if it crashes or the server reboots.

Why a BDIX VPS for Telegram Bots?

Telegram's servers route messages through their infrastructure, so your bot doesn't need to be in Bangladesh for Bangladeshi users to get fast responses. The bottleneck is your bot's response time — how quickly it processes the incoming message and sends a reply.

A BDIX VPS gives you:

  • 100% uptime (not dependent on your laptop or home internet)
  • Fast CPU response for processing messages quickly
  • A static IP address (useful for webhook mode)
  • Root access to install any libraries your bot needs

Plans start at ৳499/mo — less than most coworking space day passes in Dhaka.

Two Ways to Run a Telegram Bot: Polling vs Webhook

Before deploying, understand the two connection modes:

Polling Mode

Your bot repeatedly asks Telegram's servers "any new messages?" This is easier to set up — no domain or SSL required. Works fine for most bots. The downside is slightly higher latency and unnecessary API calls when there's nothing happening.

Webhook Mode

Telegram sends messages directly to your server via HTTPS. Faster response, more efficient, but requires a domain name and a valid SSL certificate. Better for production bots with high traffic.

This guide covers both. Start with polling — switch to webhook when you need the performance.

Setting Up the Server

SSH into your VPS and make sure it's updated:

sudo apt update && sudo apt upgrade -y

For Python Bots

Install Python and the python-telegram-bot library:

sudo apt install python3 python3-pip python3-venv -y
mkdir ~/mybot && cd ~/mybot
python3 -m venv venv
source venv/bin/activate
pip install python-telegram-bot

Upload your bot files to the server using SCP:

scp -r /path/to/your/bot/* yourname@YOUR_VPS_IP:~/mybot/

Or clone from git:

git clone https://github.com/yourusername/your-bot.git ~/mybot

For Node.js Bots

Install Node.js:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install nodejs -y
mkdir ~/mybot && cd ~/mybot

Upload your bot files and install dependencies:

npm install

Managing the Bot Process with PM2

Without a process manager, your bot stops when you close the SSH session. PM2 keeps it running permanently and handles restarts automatically.

Install PM2 globally:

sudo npm install -g pm2

Start a Python Bot

cd ~/mybot
pm2 start "venv/bin/python bot.py" --name "telegram-bot"

Start a Node.js Bot

cd ~/mybot
pm2 start bot.js --name "telegram-bot"

Make PM2 Survive Reboots

pm2 startup
# Run the command PM2 outputs (it will be a sudo command)
pm2 save

Now your bot restarts automatically if it crashes or the server reboots.

Useful PM2 Commands

# Check bot status
pm2 status

# View logs (press Ctrl+C to exit)
pm2 logs telegram-bot

# Restart bot after code changes
pm2 restart telegram-bot

# Stop bot
pm2 stop telegram-bot

# Delete from PM2
pm2 delete telegram-bot

Setting Up Webhook Mode (Optional but Recommended for Production)

For webhook mode, you need:

  1. A domain name pointing to your VPS IP
  2. A valid SSL certificate on port 443

Install Nginx and Certbot:

sudo apt install nginx certbot python3-certbot-nginx -y

Create an Nginx config for your bot's webhook endpoint:

sudo nano /etc/nginx/sites-available/bot
server {
    listen 80;
    server_name yourdomain.com;

    location /webhook {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
sudo ln -s /etc/nginx/sites-available/bot /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d yourdomain.com

In your bot code, register the webhook:

# Python example with python-telegram-bot v20+
import asyncio
from telegram.ext import Application

async def main():
    app = Application.builder().token("YOUR_BOT_TOKEN").build()
    # ... add handlers ...
    await app.run_webhook(
        listen="127.0.0.1",
        port=8080,
        url_path="/webhook",
        webhook_url="https://yourdomain.com/webhook"
    )

asyncio.run(main())

Storing Sensitive Data: Environment Variables

Never hardcode your bot token in the code. Use environment variables:

nano ~/mybot/.env
BOT_TOKEN=your_actual_token_here
DATABASE_URL=sqlite:///data.db

In Python, load with python-dotenv:

pip install python-dotenv
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("BOT_TOKEN")

In Node.js, use the dotenv package similarly.

Monitoring and Alerts

PM2 has a built-in monitor:

pm2 monit

This shows real-time CPU and memory usage per process. For a simple Telegram bot, memory usage should stay under 100 MB. If you see it growing over hours, there's likely a memory leak in your code.

For uptime monitoring, set up a free account on UptimeRobot and point it at your server's IP or webhook URL. You'll get an SMS or Telegram notification (ironic but useful) if your bot server goes down.

Running Multiple Bots on One VPS

PM2 can manage multiple processes. Each bot runs independently:

pm2 start bot1.js --name "bot-sales"
pm2 start bot2.py --name "bot-support" --interpreter python3
pm2 save

On a base BDIX VPS with 1 GB RAM, you can comfortably run 5–10 simple Telegram bots simultaneously. More RAM means more bots — upgrade your plan when needed.

Cost Breakdown

Running a Telegram bot on SNBD HOST BDIX VPS:

  • VPS: ৳499/mo (1 vCPU, 1 GB RAM)
  • Domain (if using webhook): ~৳1,000/year (~৳83/mo)
  • SSL certificate: Free (Let's Encrypt)
  • Total: ~৳582/mo for a bot that runs 24/7 with 99.9% uptime

That's less than what most businesses in Bangladesh spend on printed business cards per month.

telegram botbdix vpspython botnode.js botbot hosting bangladeshvps bangladesh24/7 bot
S

Written by

SNBD Host Team

The SNBD Host team shares hosting guides, automation tips, and business growth strategies for Bangladeshi entrepreneurs.

Share Article