# How do you deploy a Node.js app on a VPS?

> How to deploy a Node.js app on a VPS in 6 steps: Node 26 LTS via nvm, a systemd service or pm2, and nginx as a reverse proxy.

- URL: https://jadekvm.com/guides/how-to-deploy-a-nodejs-app-on-a-vps/
- Last updated: 2026-11-16
- Publisher: JadeKVM (https://jadekvm.com)

This is how to deploy a Node.js app on a VPS running Debian 13 or Ubuntu 24.04, with a restart policy and nginx in front.

**Quick answer — How do you deploy a Node.js app on a VPS?**

To deploy a Node.js app on a VPS, create an app user, install the current LTS, Node 26, with nvm, copy the code, run it as a systemd service on 127.0.0.1:3000, then put nginx in front as a reverse proxy with HTTPS. **JadeKVM** servers give root on a KVM kernel, so pm2 works too.

**In brief**

- **No root for the app**: run it as a plain user with its own home folder.
- **Node 26 LTS**: nodejs.org listed it as the latest LTS on 16 November 2026.
- **systemd or pm2**: both restart a crashed app and start it at boot.
- **nginx in front**: the app listens on 127.0.0.1; nginx serves ports 80 and 443.

## How to deploy a Node.js app on a VPS in 6 steps?

The example app listens on port 3000 and starts with node server.js.

1. **Create an app user** — Run sudo adduser --disabled-password app and switch to it with sudo -iu app.
2. **Install Node.js** — Install nvm, then run nvm install --lts. Note the path that which node prints.
3. **Copy the code** — Clone the repository or upload it with rsync, then run npm ci --omit=dev.
4. **Create the service** — Write a systemd unit with that node path, Restart=on-failure and the app user.
5. **Add nginx** — Proxy example.com to http://127.0.0.1:3000 and reload nginx.
6. **Add HTTPS** — Run certbot for nginx so the proxy serves TLS.

## Which is better for a Node.js app: systemd or pm2?

*Two ways to keep a Node.js app running on a VPS, compared on setup, restarts and logs*

| Point | systemd service | pm2 | Best for |
| --- | --- | --- | --- |
| Install | Built into Debian and Ubuntu | npm install -g pm2 | systemd: nothing extra |
| Restart on crash | Restart=on-failure | Automatic | Tie |
| Start at boot | systemctl enable | pm2 startup, pm2 save | Tie |
| Logs | journalctl -u app | pm2 logs | systemd: one place for all services |
| Cluster mode | One unit per process | pm2 start -i max | pm2 on multi-core plans |

## How do you install Node.js 26 LTS with nvm?

**Install nvm as the app user, then let it fetch the LTS build.** The distro packages lag: Ubuntu 24.04 ships Node 18 in its archive. nvm installs current versions into the user's home, with no root needed.

The nvm release used here, v0.41.0, is the one its README showed on 16 November 2026. Check the README for a newer tag before you run it.

*nvm and Node LTS (as the app user)*

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc
nvm install --lts
node -v
which node
```

## How do you run the app as a systemd service?

**Write a unit file that names the user, the folder and the full node path, then enable it.** Paste the path printed by `which node` into ExecStart. systemd restarts the app 5 seconds after a crash and starts it at boot.

Keep secrets in an environment file readable by root only. Logs go to the journal: `journalctl -u app -f` follows them live.

*/etc/systemd/system/app.service*

```ini
[Unit]
Description=Node.js app
After=network-online.target
Wants=network-online.target

[Service]
User=app
WorkingDirectory=/home/app/myapp
ExecStart=/home/app/.nvm/versions/node/v26.13.1/bin/node server.js
Environment=NODE_ENV=production PORT=3000 HOST=127.0.0.1
EnvironmentFile=-/etc/app.env
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
```

## How do you put nginx in front of the Node.js app?

**A short server block passes requests to 127.0.0.1:3000 and keeps WebSocket upgrades working.** Run `sudo systemctl daemon-reload` and `sudo systemctl enable --now app` first. Then add the block below and reload nginx.

The guide on [how to host a website on an Asia VPS](https://jadekvm.com/guides/how-to-host-a-website-on-an-asia-vps/ "How do you host a website on an Asia VPS?") explains sites-available. Certbot then adds TLS, as in [how to install a free SSL certificate](https://jadekvm.com/guides/how-to-install-a-free-ssl-certificate-on-a-vps/ "How do you install a free SSL certificate on a VPS?").

*nginx reverse proxy*

```nginx
server {
    listen 80;
    server_name example.com;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
```

## Which is the best VPS city for a Node.js API in Asia?

**Place the API next to its main clients.** JadeKVM read WonderNetwork's public pings on 16 November 2026: Tokyo sits 104 ms from San Francisco, Hong Kong 162 ms. Singapore sits 55 ms from Mumbai. Latency figures on JadeKVM pages are public averages measured by WonderNetwork between its own servers on 16 November 2026; they show how far apart the cities sit on the network, not a promise about any one JadeKVM server. An API serving both Asia and the US West Coast often fits Tokyo; see [the US West Coast page](https://jadekvm.com/us-west-coast-to-asia-vps/ "Which Asian VPS city is closest to the US West Coast?").

Pendant offers 1 shared vCPU, 3 GB RAM, 45 GB NVMe, 1 TB a month, enough for most APIs.

## Questions about deploying Node.js on a VPS

### Which Node.js version should I deploy in 2026?

The current LTS line. On 16 November 2026, nodejs.org listed Node 26 as the latest LTS, with 24 and 22 still supported.

### Is pm2 better than systemd for Node.js?

pm2 adds cluster mode and a friendly CLI. systemd needs no extra tool. Both restart a crashed app and survive reboots.

### Should the Node.js app listen on port 80?

No. Keep it on 127.0.0.1 with a high port and let nginx handle 80 and 443.

### How do I deploy updates?

Pull the new code, run npm ci, then sudo systemctl restart app. Keep the old release folder for a quick rollback.

### Can the app send email?

Yes, through a mail provider on port 465 or 587. Outbound port 25 is closed on JadeKVM servers.

**Verdict**

- **A plain user, Node LTS via nvm, a systemd unit and nginx in front** is a robust Node.js deployment.
- Choose pm2 if you want cluster mode on a multi-core plan such as Bangle.

## Sources

1. [Download Node.js](https://nodejs.org/en/download) — OpenJS Foundation (read 2026-11-16)
2. [nvm, Node Version Manager](https://github.com/nvm-sh/nvm) — nvm-sh (read 2026-11-16)
3. [systemd.service(5) manual page](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html) — freedesktop.org / systemd (read 2026-11-16)
4. [PM2 startup script](https://pm2.keymetrics.io/docs/usage/startup/) — PM2 (read 2026-11-16)
5. [ngx_http_proxy_module](https://nginx.org/en/docs/http/ngx_http_proxy_module.html) — nginx.org (read 2026-11-16)
6. [WonderNetwork: pings from Tokyo](https://wondernetwork.com/pings/Tokyo) — WonderNetwork (read 2026-11-16)

**Deploy your Node.js app in Tokyo** Pendant offers 1 vCPU / 3 GB / 45 GB for $4.50 a month on 12 months. [Order Pendant in Tokyo](https://jadekvm.com/app/checkout/?plan=pendant&term=12m&location=jp-tyo&from=how-to-deploy-a-nodejs-app-on-a-vps&lang=en) · [See every plan](https://jadekvm.com/pricing/ "How much does a JadeKVM server cost per month?")

---

JadeKVM: JadeKVM sells Linux KVM VPS in Hong Kong, Tokyo and Singapore, paid in crypto with no ID document, and publishes the measured latency from each city to the rest of Asia. 5 plans from 1 to 16 GB of RAM cost the same in all three cities and, on the 12-month term, sit at least 25% under a named comparable no-KYC crypto plan read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
