Posted on Leave a comment

Telegram Bot Hosting: A Complete Guide from Choosing a VPS to Getting Up and Running 24/7-bot

Connecting to the server via SFTP.

Disclosure: This site may contain affiliate links. If you make a purchase through these links, I may receive a commission at no additional cost to you. However, all opinions are my own.

telegram bot.
Telegram has moved beyond being just a messenger, becoming a global platform for Mini Apps, complex AI assistants, and full-fledged business interfaces. To ensure your bot doesn’t just “respond to commands” but works reliably 24/7, it’s important to choose the right “home” for its code and configure the environment appropriately.

1. Selecting hosting for the bot

Forget about regular web hosting. For a bot, the only reliable solution is a VDS/VPS (Virtual Private Server). This gives you complete control over the operating system, the ability to install any libraries, and guaranteed resources.

What to look for when choosing:

    • Location: If your audience is primarily located in the CIS, choose servers in nearby data centers for minimal ping.
    • Tech stack: Make sure your provider allows you to install up-to-date versions of Python (3.12+), Node.js, or Docker.
    • AI support: If your bot uses local language models (LLM), you may need GPU-accelerated servers. For regular bots, standard processing power is sufficient.
    • Scalability: You can add more RAM in one click if your bot becomes popular.
To find the best option, I recommend checking out the best VDS/VPS ratings, where you can compare prices from different providers to avoid overpaying for unnecessary capacity.

2. System requirements and tariffs

Currently, the hardware requirements have increased slightly, but remain affordable:
    • A simple bot (text commands): 1 GB RAM, 1 CPU Core. A VPS for €1 per month is more than enough for even a few small scripts.
    • Bot with database (PostgreSQL/Redis): 2 GB RAM.
    • OS: The clear choice is a modern operating system, such as Ubuntu 24.04 LTS or 26.04 LTS. Most documentation and libraries are written specifically for these distributions.
Important note: Free solutions like the old Heroku are long gone or have become too unstable. For a serious project, it’s better to budget for a paid VPS—the stability and dedicated IP are worth it.

3. Server setup

Let’s assume you’ve already rented a server. Now we need to bring it online. We’ll use the SSH protocol for management.

Step 1: Connection

To manage the server we need a terminal, for example Termius, MobaXterm.
termius.
    1. Open Termius and create a new connection (New Host).
    2. Enter your hosting account details:
        • Hostname (IP Address): The address of your server.
        • Port: usually 22 (unless the hosting specifies otherwise).
        • Username: most often root.
        • Password: your password.
    1. Save the settings and click on the name of the created host in the list.
    2. If you see a black console window with a system welcome message, congratulations, you are “inside” your server.
python language module.

Step 2: Preparing the Environment

First, update the packages and install Python: sudo apt --reinstall install python3 -y sudo apt --reinstall install python3-pip -y Now let’s install the library for working with the Telegram API. pyTelegramBotAPI remains the default, but the commands are the same: pip3 install pyTelegramBotAPI --break-system-packages

Step 3: Process Manager (PM2)

To prevent the bot from crashing after closing the console and to automatically restart it if there are any crashes, install PM2. It requires Node.js: sudo apt install nodejs sudo apt install npm npm install pm2 -g

4. Uploading the code to the server

The easiest way for beginners is the SFTP protocol.
    1. In Termius, open the SFTP tab.
    2. Connect to your host.
    3. Create a folder (e.g., /root/my_bot/).
    4. Simply drag your bot files (main.py, configuration files, and the database) from your computer into this folder.
connecting to the erver via sftp.

5. Launch and control

Go to the bot folder via the console: cd folder_name pm2 start main.py --interpreter=python3 (replace main with the name of the bot's executable file) You can check the bot’s status with the pm2 list command. If the “status” column says “online,” everything is working fine.

Useful PM2 commands

    • pm2 list — view the status of all running bots.
    • pm2 logs — Check the logs (if the bot isn’t working, the reason will be there).
    • pm2 restart my_telegram_bot —Restart the bot after updating the code.
FAQ
Why does the PM2 status say “online” but the Telegram bot doesn’t respond?
The online status in PM2 only means the script is running. If the bot isn’t responding, there’s likely an error in the code itself (for example, an invalid token) or the required libraries aren’t installed. To see the real cause of the crash, use the pm2 logs command.
Dmytro Yakovenko
Leave a Reply

Your email address will not be published. Required fields are marked *