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.
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.
Use SSH to connect to your VPS:
ssh root@your_vps_ip
apt update apt install nodejs npm -y node -v
Upload your bot project to the VPS using Git or FTP. Make sure your project contains index.js and package.json.
npm install
npm install pm2 -g
pm2 start index.js --name whatsapp-bot pm2 save pm2 startup
This ensures your bot runs forever in the background.
Run logs to see the QR code:
pm2 logs
Scan the QR from WhatsApp Linked Devices.
pm2 list
You can restart or stop the bot anytime using PM2 commands.
pm2 saveHosting 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.