Guides ยท Sep 27, 2026
How to Host a Discord Bot 24/7 on a VPS (Node.js & Python)
Keep a discord.js or discord.py bot online 24/7 on a Linux VPS: upload your code, store the token safely, and auto-restart with PM2 or systemd.
Running your bot on a VPS means it stays online when your PC is off. Follow the Node.js or Python section depending on your bot.
1. Get your code onto the server
The easiest way is Git:
sudo apt update && sudo apt install -y git
git clone https://github.com/you/your-bot.git
cd your-bot
Never commit your bot token to Git. Put it in a .env file on the server instead:
echo "DISCORD_TOKEN=paste-your-token" > .env
chmod 600 .env
2a. Node.js bots (discord.js): use PM2
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
npm install
sudo npm install -g pm2
pm2 start index.js --name my-bot
pm2 save
pm2 startup # run the command it prints so the bot starts on boot
Useful commands: pm2 logs my-bot, pm2 restart my-bot, pm2 status.
2b. Python bots (discord.py, Pycord): use systemd
sudo apt install -y python3-venv
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
Create /etc/systemd/system/my-bot.service (replace the paths with yours):
[Unit]
Description=My Discord bot
After=network-online.target
[Service]
WorkingDirectory=/root/your-bot
EnvironmentFile=/root/your-bot/.env
ExecStart=/root/your-bot/.venv/bin/python bot.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now my-bot
journalctl -u my-bot -f
3. Updating your bot
git pull
pm2 restart my-bot # Node.js
sudo systemctl restart my-bot # Python
How many bots fit on one server?
Most small and medium bots use 100โ300 MB of RAM, so the 4 GB Ripple plan can run several bots plus a database at once.
Need a server for this?
Every TidalVPS VPS comes with full root access, unmetered traffic, daily backups and DDoS protection.