VPS for Node.js: LTS version, PM2 or Docker, proxy and memory
A Node.js application on a server is one or more long-lived processes that listen on a port, hold connections to the database and WebSocket clients, and must come back by themselves after a failure. Choosing a VPS comes down to three questions: which version to install, what to manage the processes with, and how much memory they will eat together with the build. The table above shows plans with 1 GB of memory or more and a 20 GB disk on KVM, where both Docker and modern Linux kernels work without restrictions.
Which Node.js version to install
For production take an LTS branch only. In October 2026 Node.js 26 moves into long-term support, Node.js 24 remains a supported LTS branch, Node.js 22 stays in maintenance mode with critical fixes only until April 2027, and support for Node.js 20 ended in spring 2026. Odd-numbered releases without LTS are not suitable for servers. From Node.js 27 the project switches to one release a year, and each of them will become LTS, so the numbering will no longer hint at the status; check the schedule on the project's website.
The package from the distribution's standard repository usually lags behind: in Ubuntu 24.04 it is Node.js 18, which is no longer supported. Install Node.js from the official package repository, through a version manager (nvm, fnm, Volta), or use the official Docker image with the version you need. Pin the version in the engines field of package.json and in .nvmrc so that the server, CI and the developer's laptop run the same branch.
PM2 or Docker
PM2 is a process manager running directly on the server. It restarts a crashed application, in cluster mode starts one process per core (pm2 start app.js -i max), and reloads them one by one without downtime with pm2 reload. For processes to survive a VPS reboot, run pm2 startup and pm2 save. PM2 logs grow without limit by default, so install the pm2-logrotate module straight away.
Docker is more convenient when a database, Redis and workers run alongside, and the environment must match CI. Use node:<version>-slim or alpine images, a multi-stage build, npm ci --omit=dev in the final layer and the restart: unless-stopped policy. Run the process as the node user rather than root, and pass signals correctly: when the container stops, the application should close its connections rather than be cut off. Setting up a server for containers is covered on the VPS for Docker page.
For one small application a systemd unit with Restart=always is enough; an extra layer is not required.
A reverse proxy in front of the application
Do not expose the Node.js port to the internet directly. The application listens on 127.0.0.1:3000, and in front of it sits Nginx or Caddy, which:
- accepts HTTPS on port 443 and renews the Let's Encrypt certificate itself;
- serves static files without involving Node.js and compresses responses;
- passes the
X-Forwarded-ForandX-Forwarded-Protoheaders; in Express,trust proxyis enabled to take them into account; - lets WebSocket through: in Nginx this needs the
UpgradeandConnectionheaders and an increasedproxy_read_timeout; - limits the request body size and the rate of calls to sensitive routes.
This way the application does not need root rights for port 80 or 443, and one server can host several projects on different domains. A Telegram Mini App backend works the same way: Telegram opens the app and sends the bot webhook only over HTTPS; what else such a server needs is covered in A server for a Telegram Mini App.
How much memory to take
A simple Express or Fastify API process takes 50–100 MB after startup, a Next.js or Nuxt server with page rendering 150–400 MB. In cluster mode multiply by the number of processes. The V8 heap is limited, and with a leak the process crashes with a JavaScript heap out of memory error; the limit is set with the --max-old-space-size flag in megabytes. Set it below the available memory with room for buffers and the system itself, and add max_memory_restart in PM2 as insurance.
The main memory hog is not the running application but the build: npm install of a large project, a frontend build with Vite or webpack, or next build easily take 1–2 GB or more. On a 1 GB server a build can push out the running application. Build the artefact in CI and deploy the ready files; for builds there is the VPS for CI/CD runners selection. For a bot or a small API 1 GB is enough (an example calculation is on the VPS for a Telegram bot page); for an SSR site with a database alongside, 2–4 GB and 2 cores. The disk fills up with node_modules, the npm cache and Docker images, so 20 GB is a sensible minimum rather than a reserve.