TABI CLOUD
VPS

Host a Discord bot on a VPS with systemd or pm2

6 min read · Updated October 2026 · By Tabi Cloud

Running a bot in a terminal stops when you log out. A process manager keeps it alive, restarts it if it crashes and starts it at boot. Below are two common options. Commands target Ubuntu and Debian and may differ elsewhere.

Prepare the bot

  1. Install runtimes, for example sudo apt install nodejs npm -y or sudo apt install python3 python3-venv -y
  2. Copy your bot to a folder such as /home/deploy/mybot
  3. Install dependencies with npm install, or create a venv and run pip install -r requirements.txt
  4. Keep your token in an environment file, never in public code

Option 1: systemd

systemd is built into most Linux systems, so nothing extra is needed.

  1. sudo nano /etc/systemd/system/mybot.service
  2. Paste a unit like this:

[Unit]

Description=My Discord bot

After=network-online.target

[Service]

User=deploy

WorkingDirectory=/home/deploy/mybot

EnvironmentFile=/home/deploy/mybot/.env

ExecStart=/usr/bin/node index.js

Restart=always

RestartSec=5

[Install]

WantedBy=multi-user.target

  1. sudo systemctl daemon-reload
  2. sudo systemctl enable --now mybot
  3. sudo systemctl status mybot

For Python, change ExecStart to something like /home/deploy/mybot/venv/bin/python bot.py.

View logs

Option 2: pm2 for Node.js

  1. sudo npm install -g pm2
  2. pm2 start index.js --name mybot
  3. pm2 save
  4. pm2 startup, then run the command it prints

Useful commands are pm2 list, pm2 logs mybot, pm2 restart mybot and pm2 stop mybot.

Which should you choose

Tips

Your VPS stays up 24/7 on Tabi Cloud, and our team can help via Discord ticket or email.

Want your own server? Join our Discord and tell us the game. We set it up and send you the details. Need help with an error from this guide? Open a ticket there.

GET STARTED ON DISCORD

More guides

VPSWhat is a VPS and how is it different from shared hosting?VPSHow to choose a VPS plan: vCPU, RAM and diskVPSFirst steps on a new Linux VPS: SSH, updates, user and keys