How to Host a Python Telegram Bot 24/7
Stop running your Telegram bot on your laptop. Deploy it to a 24/7 server using Pterodactyl with this step-by-step guide.
How to Host a Python Telegram Bot 24/7
If you built a Telegram bot using python-telegram-bot, aiogram, or Telebot and run it on your laptop, it goes offline when your internet drops or you close the lid. To keep it running permanently, you need a dedicated hosting server.
Step 1: Create requirements.txt
Run in your bot folder:
pip freeze > requirements.txt
Step 2: Secure Your API Token
Never hardcode your Telegram token directly in your code. Use environment variables:
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("TELEGRAM_TOKEN")
Create a .env file: TELEGRAM_TOKEN=123456789:YOUR_TOKEN_HERE
Step 3: Upload to the Panel
- Zip all your files (exclude venv and pycache).
- Log in to VisiHost Pterodactyl Panel.
- Go to Files for your server.
- Upload and unarchive the zip.
Step 4: Configure Startup
- Go to the Startup tab.
- Set Startup File to your main Python file (e.g. main.py).
- Select the correct Python version.
Step 5: Start Your Bot
Click Start in the Console tab. The panel runs pip install -r requirements.txt then executes your script. When you see your startup messages, your bot is live 24/7.
Resource Requirements
Most Python Telegram bots run comfortably on 256 MB to 512 MB of RAM. VisiHost Telegram Bot Hosting starts at Rs 10 per month with 512 MB RAM on AMD EPYC processors. Pair with Database Hosting if your bot needs persistent storage.
Keep Your Discord Bot Online 24/7
No sleep scripts needed. High-performance hosting for Node.js and Python.
Explore more about VisiHost
Check out our other affordable hosting packages and guides.