CloudLinux.ro
Web servers

How to deploy a Node.js app to production

Updated 7/20/2026

Running node app.js in a terminal does not keep the app alive after you disconnect. Here is how to deploy it properly, with auto-restart and an HTTPS domain.

1. Install Node.js

curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs

2. Run the app with PM2

PM2 keeps the app running and restarts it if it stops:

npm install -g pm2
cd /var/www/app
pm2 start app.js --name my-app
pm2 startup
pm2 save

3. Put Nginx in front

The app listens on an internal port (e.g. 3000); Nginx receives public traffic. See How to set up Nginx as a reverse proxy.

4. Add HTTPS

See Free SSL certificate with Let's Encrypt.

Useful PM2 commands

pm2 list
pm2 logs my-app
pm2 restart my-app

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials