Skip to content
  • Automation
  • Linux VPS
  • Ubuntu 24.04

Telegram and Discord bot hosting on a VPS

A Telegram or Discord bot runs well on a GhostRDP Linux VPS Basic plan with 2 vCPU and 6 GB RAM in Germany or the Netherlands, from €5.99/mo.

This guide runs a Python bot (python-telegram-bot or discord.py) as a systemd service, so it starts on boot and comes back after a crash. Node.js bots follow the same pattern with node instead of python.

  • Always online

    A service that restarts by itself and survives reboots.

  • Python or Node.js

    Same setup for python-telegram-bot, discord.py or discord.js.

  • No open ports

    Polling bots only make outgoing connections.

Plans for Telegram and Discord bots

A chat bot needs very little. Basic runs several bots at once; pick a bigger plan for large Discord bots with many servers or heavy tasks like music or AI.

  • Linux VPS Basic

    Recommended

    €5.99/mo

    €5.09/mo billed yearly, save €10/year

    • 2 vCPU
    • 6 GB ECC RAM
    • 40 GB NVMe
    • 1 Gbps port
    Order Basic
  • Linux VPS Standard

    €12.99/mo

    €11.04/mo billed yearly, save €23/year

    • 4 vCPU
    • 8 GB ECC RAM
    • 70 GB NVMe
    • 1 Gbps port
    Order Standard
  • Linux VPS Pro

    €25.99/mo

    €22.09/mo billed yearly, save €46/year

    • 6 vCPU
    • 12 GB ECC RAM
    • 90 GB NVMe
    • 1 Gbps port
    Order Pro

What you need

  • Operating system
    Linux VPS with Ubuntu 24.04
  • Minimum resources
    1 vCPU and 512 MB RAM for a small bot
  • Bot token
    From @BotFather on Telegram, or the Discord Developer Portal (Bot tab)

Official site: core.telegram.org/bots

How to install Telegram and Discord bots

Written for Ubuntu 24.04 from the official instructions. Run the commands as root and replace YOUR_SERVER_IP with your server's address.

  1. 1

    Connect to your server over SSH

    Use the IP address and root password from your welcome email (the server page has a Copy SSH command button). Windows 10 and 11, macOS and Linux all include an SSH client in the terminal.

    Shell
    ssh root@YOUR_SERVER_IP
  2. 2

    Update the system

    Install the latest security updates before you add anything else.

    Shell
    apt update && apt -y upgrade
  3. 3

    Install Python and create a bot user

    Run the bot as its own user, not as root.

    Shell
    apt install -y python3-venv
    useradd -m -s /bin/bash bot
    sudo -u bot mkdir -p /home/bot/app
    sudo -u bot python3 -m venv /home/bot/venv
  4. 4

    Install the bot library

    Install the one you use.

    Shell
    # Telegram
    sudo -u bot /home/bot/venv/bin/pip install python-telegram-bot
    
    # Discord
    sudo -u bot /home/bot/venv/bin/pip install discord.py
  5. 5

    Add your code and token

    Upload your bot with scp, or write this minimal Telegram bot that answers /start. Put the token in an .env file that only the bot user can read.

    Shell
    cat > /home/bot/app/bot.py <<'EOF'
    import os
    from telegram import Update
    from telegram.ext import Application, CommandHandler, ContextTypes
    
    async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
        await update.message.reply_text("Hello, I'm online.")
    
    app = Application.builder().token(os.environ["BOT_TOKEN"]).build()
    app.add_handler(CommandHandler("start", start))
    app.run_polling()
    EOF
    echo 'BOT_TOKEN=paste-your-token-here' > /home/bot/app/.env
    chmod 600 /home/bot/app/.env
    chown -R bot:bot /home/bot/app
  6. 6

    Run it as a service

    systemd loads the token from .env, starts the bot on boot and restarts it after a crash.

    Shell
    cat > /etc/systemd/system/chatbot.service <<'EOF'
    [Unit]
    Description=Chat bot
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    User=bot
    WorkingDirectory=/home/bot/app
    EnvironmentFile=/home/bot/app/.env
    ExecStart=/home/bot/venv/bin/python /home/bot/app/bot.py
    Restart=always
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable --now chatbot
    journalctl -u chatbot -f

After installing

  • Test it
    Send /start to your bot in Telegram. For Discord, invite the bot from the Developer Portal (OAuth2 > URL Generator) and check it shows as online.
  • Open ports
    None for long polling (Telegram) or the Discord gateway. Only webhook bots need an open port and HTTPS.
  • Updating
    Upload the new code and run systemctl restart chatbot.

Telegram and Discord bots questions

Which plan do I need for a Telegram or Discord bot?

The Basic Linux VPS is plenty for most bots, including several bots on one server.

Polling or webhooks for Telegram?

Polling is simplest: no domain, no certificate and no open port. Webhooks need a domain with HTTPS pointing at your server.

Can I host a Node.js bot instead?

Yes. Install Node.js, then use the same service file with ExecStart set to your node command (for example /usr/bin/node /home/bot/app/index.js).

What happens if the bot crashes?

systemd restarts it 5 seconds later, and starts it again after a reboot.

Stuck on a step? Our team answers on live chat and in tickets.

More on GhostRDP

Run Telegram and Discord bots on your own server.

Online in minutes. Pay with crypto, no ID needed.