Node.js powers many modern web applications and APIs, including frameworks such as Next.js, NestJS and Express. Moving one from a laptop to a server takes a few extra pieces.
A process manager
Use a process manager such as PM2 or a systemd service, so the app restarts if it crashes and starts again after a reboot. PM2 can also run several instances to use every CPU core.
A reverse proxy in front
Put Nginx or Caddy in front of the app. It terminates HTTPS, serves static files efficiently, compresses responses and forwards requests to Node on a local port. Never run the app as root to bind port 80.
HTTPS
Get a free certificate with Let's Encrypt (Caddy does it automatically). Redirect HTTP to HTTPS.
Environment and secrets
Keep configuration and secrets in environment variables or an env file readable only by the app's user, never in your Git repository. Set NODE_ENV to production.
Logs and monitoring
Rotate logs so they do not fill the disk, and watch CPU, memory and response times. Alert on the app being down, not just the server.
Deployments
A simple, reliable flow: pull the new version, install dependencies, build, then reload the process manager without downtime. Keep the previous build so you can roll back quickly.
Databases and backups
If the database runs on the same VPS, bind it to localhost only and back it up off the server every day.
Sizing
Small APIs run happily on 1 to 2 vCPU and 2 to 4 GB of memory; server-side rendering frameworks and build steps want more. Measure under real load.
At IDX
IDX cloud VPS plans give you full root access, NVMe storage and snapshots for safe deployments. If you would rather not manage the server, our managed services team can run it for you.
IDX on digital infrastructure
Back to blog →