SMD HOST BLOGS VPS SERVER

How to Host WhatsApp Bot on VPS with PM2 (No Downtime)

Running your WhatsApp bot on a local computer is fine for testing, but it is not reliable for real usage. The moment your system turns off, your bot goes offline. This is why professional bot developers prefer hosting their bots on a VPS and managing the process with PM2.

This guide explains the exact steps to host your Baileys WhatsApp bot on a VPS server and keep it running 24/7 without crashes, restarts, or downtime.

What is a VPS?

A VPS (Virtual Private Server) is an online server that runs all the time. You can install Node.js, upload your bot files, and run your bot continuously just like on your computer, but without interruptions.

Why Use PM2?

Step 1: Connect to Your VPS

Use SSH to connect to your VPS:

ssh root@your_vps_ip

Step 2: Install Node.js

apt update
apt install nodejs npm -y
node -v

Step 3: Upload Your Bot Files

Upload your bot project to the VPS using Git or FTP. Make sure your project contains index.js and package.json.

Step 4: Install Dependencies

npm install

Step 5: Install PM2

npm install pm2 -g

Step 6: Start Bot with PM2

pm2 start index.js --name whatsapp-bot
pm2 save
pm2 startup

This ensures your bot runs forever in the background.

Step 7: Pair WhatsApp

Run logs to see the QR code:

pm2 logs

Scan the QR from WhatsApp Linked Devices.

Step 8: Monitor Your Bot

pm2 list

You can restart or stop the bot anytime using PM2 commands.

Common Mistakes to Avoid

Conclusion

Hosting your WhatsApp bot on a VPS with PM2 is the most reliable method to ensure zero downtime. This setup is used by professional developers because it provides stability, control, and continuous uptime.