Back to all guides
Bot Hosting

Hosting Your Own Discord Bot 24/7 (PM2)

4 read2026-04-10

If you start your bot by simply running node index.js over SSH, the bot will die the second you close the terminal. PM2 solves this trivially.

1. Install Node.js and PM2

First, install NPM and PM2 globally.

bash
sudo apt update
sudo apt install nodejs npm -y
sudo npm install pm2 -g

2. Start Your Bot

Navigate to your bot's folder and use PM2 to start it.

bash
cd /path/to/your/bot
pm2 start index.js --name "MyDiscordBot"

3. Keep Alive on Server Reboots

If your VPS restarts, PM2 needs to know how to start your bot automatically.

bash
pm2 startup
# Run the command PM2 outputs to the console

pm2 save

4. Viewing Logs

To see your bot's live console output (console.log):

bash
pm2 logs MyDiscordBot
KVM Linux VPS

Looking for the right Linux VPS?

Put your project into practice right away: Our KVM VPS provide full root access, lightning-fast NVMe storage, and reliable KVM isolation. Flexible prepaid billing with no subscription and personal Discord support.

Full Root Access (SSH)
Datacenter NVMe SSD
4+ Tbps DDoS Protection
100% Prepaid (No Subscription)