Launch pricingNo GST added. What you see is what you pay.

Deploy apps · 15 min

Deploy a Node.js app with PM2

Run a Node.js app on your server and keep it running after crashes and reboots.

PM2 keeps your Node.js app running: it restarts it if it crashes and starts it again after a reboot.

1. Install Node.js and PM2

bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs git
sudo npm install -g pm2

2. Get your code onto the server

bash
cd /opt
sudo git clone https://github.com/you/your-app.git
sudo chown -R $USER:$USER your-app
cd your-app
npm ci

3. Start it with PM2

bash
pm2 start npm --name my-app -- start
pm2 save
pm2 startup

pm2 startup prints one more command. Copy and run it, so your app starts after a reboot.

4. Make it reachable

Your app probably listens on a port like 3000. Either:

Everyday commands

bash
pm2 status        # what's running
pm2 logs my-app   # see the output
pm2 restart my-app

Updating your app

bash
cd /opt/your-app && git pull && npm ci && pm2 restart my-app

Stuck? Contact us or open a support ticket from your panel.