To deploy a Node.js app on a VPS, you create a Linux server, install Node.js, run your app with PM2, put Nginx in front of it, and add a free HTTPS certificate. A VPS (virtual private server) is a slice of a big server that only you control. This guide gives each command in order. The commands follow the official docs of Node.js, Nginx, Certbot, PM2 and Ubuntu (checked 14 November 2026).
You will need a server with Ubuntu, a domain name, and a Node.js app that listens on a port such as 3000.
Disclosure: the Hostinger links and the coupon code below are part of Hostinger's affiliate programme. Tutorsbot may earn a commission if you buy, at no extra cost to you.
Deploy node js app on VPS: what you need first
You need four things: a VPS with at least 1 GB of RAM, a domain name, an SSH key, and an app that starts with one command. RAM is the working memory of the server. More RAM gives your app more room.
This guide uses Ubuntu, the Linux system that most VPS companies offer. The steps are the same on DigitalOcean, Hetzner and Hostinger. Only the sign-up screens differ.
Point your domain at the server first. In your domain settings, add an A record (a DNS entry that maps a name to an IP address) that holds the server's IP. Certbot needs this in step 5.
How to deploy node js application on VPS
You do it in six steps: log in, install Node.js, start the app with PM2, add Nginx, add HTTPS, then lock down the server. Each step below shows the exact commands.
Step 1: Create the server and log in with SSH
Create a server with an Ubuntu image in your provider's dashboard. Add your SSH key while you do it. SSH is the tool that lets you control the server from your own computer.
On your own computer, make a key pair. The Ubuntu documentation recommends the ed25519 type:
ssh-keygen -t ed25519
ssh-copy-id username@server_ip
Many providers copy your key for you when you create the server. In that case, skip the second line.
Next, make a normal user so that you do not work as root. The Ubuntu user guide gives sudo adduser username for a new user. It says to add a user to the sudo group to give it full admin rights:
sudo adduser deploy
sudo adduser deploy sudo
If you are already logged in as root, leave out sudo. Log in as the new user from now on. The Ubuntu OpenSSH page warns that a wrong SSH setting can lock you out, so keep one session open while you test changes.
Step 2: Install Node.js the official way
The nodejs.org download page lists nvm for Linux. nvm is a tool that installs and switches Node.js versions. Note that nodejs.org says the Node.js project does not maintain these installer scripts. The page shows this:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
\. "$HOME/.nvm/nvm.sh"
nvm install 26
node -v
npm -v
On 14 November 2026, nodejs.org marks version 26 as the current LTS (long-term support) release, and its release index lists v26.13.1. Check the page for the newest major version before you copy the number. The last two commands should print version numbers.
Now copy your app to the server. If your code is in a Git repository, use git clone. Then run npm install inside the project folder. If you need a database, our PostgreSQL vs MySQL guide helps you pick one.
Step 3: How to deploy node js application in production with PM2
Use a process manager so your app restarts after a crash or a reboot. PM2 is a process manager for Node.js. Its quick start gives these commands:
npm install pm2@latest -g
pm2 start app.js
pm2 list
pm2 logs
Replace app.js with your own start file. Add --name myapp to give it a short name.
Now make PM2 start at boot. The PM2 startup page says to run pm2 startup without sudo. PM2 prints one command that starts with sudo env PATH=. Copy that line and run it. Then save the app list:
pm2 startup
pm2 save
PM2 detects systemd on Ubuntu and writes the unit for you. systemd is the part of Linux that starts services at boot.
After a code update, run pm2 reload myapp or pm2 restart myapp.
Make your app listen on 127.0.0.1, not on all addresses. Then nobody can reach it except through Nginx.
Step 4: Nginx reverse proxy nodejs
A reverse proxy is a server that takes web requests and passes them to your app. Nginx listens on ports 80 and 443 and forwards traffic to your Node.js port.
The nginx.org install page gives these steps for Ubuntu with the stable package:
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
https://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
sudo apt update
sudo apt install nginx
The page also shows a command that checks the key fingerprint. Run it too. The pinning step makes apt prefer nginx.org packages over the ones from Ubuntu. This uses the stable repository, which is the default on that page. The package from nginx.org reads every file in /etc/nginx/conf.d/ that ends in .conf. Create /etc/nginx/conf.d/myapp.conf with the proxy example from the Nginx documentation, changed for your domain and port:
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Check the file, then reload Nginx. The -t switch tests the config. The -s reload switch applies it:
sudo nginx -t
sudo nginx -s reload
Open http://example.com. You should see your app. If your app uses WebSockets, read the nginx.org WebSocket page. The docs say that proxying them needs extra settings.
Step 5: Nginx node js reverse proxy https with Let's Encrypt
Certbot gets a free certificate from Let's Encrypt and edits your Nginx file for you. The Certbot site recommends the snap install on Linux. A snap is a packaged app that updates itself. Your domain must already point to the server.
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot
sudo certbot --nginx
sudo certbot renew --dry-run
If you installed Certbot with apt before, remove that copy first, as the Certbot page says. The Certbot page also says its install adds a cron job or systemd timer that renews certificates. The last command tests that renewal works.
Visit https://example.com and look for the lock icon.
Step 6: Firewall and updates
A firewall blocks every port you do not open. Ubuntu uses UFW. Allow SSH first, or you will lock yourself out. The Ubuntu firewall guide gives these commands:
sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
sudo ufw status
Your Node.js port stays closed. Nginx reaches it on the same machine, so the outside world does not need it.
For updates, Ubuntu installs the unattended-upgrades package by default. The Ubuntu docs say it applies security updates once a day. It does not reboot the server unless you turn that on. Run sudo apt update and sudo apt upgrade yourself now and then. Reboot when an update asks for it.
Use the same pattern for new code. Pull it, run npm install, then run pm2 reload myapp. To automate this, see GitLab vs GitHub.
Node js server vs nginx
Node.js runs your code. Nginx handles the web traffic in front of it. You use both together, and they do not replace each other.
Nginx ends the HTTPS connection, serves files, and passes requests to Node.js. Your app only runs your logic. This also lets you run several apps on one server. Each app gets its own port and its own server block.
You can skip Nginx for a small test. For a real site, use the reverse proxy.
Node js hosting cost on a VPS
A VPS that runs a Node.js app costs about $6 to $24 a month in 2026, according to the providers' pricing pages. The price depends on RAM and on how long you commit. Hostinger asks for 24 months up front, while DigitalOcean and Hetzner bill by the hour with a monthly cap.
| Plan | RAM | 12 months | 24 months | 48 months |
|---|---|---|---|---|
| Hostinger KVM 1 ($6.49 per month, then $11.99) | 4 GB | $155.76 (24-month term only) | $155.76 | $443.52 |
| Hostinger KVM 2 ($8.79 per month, then $14.99) | 8 GB | $210.96 (24-month term only) | $210.96 | $570.72 |
| DigitalOcean Basic Droplet ($12 per month) | 2 GiB | $144 | $288 | $576 |
| DigitalOcean Basic Droplet ($24 per month) | 4 GiB | $288 | $576 | $1,152 |
| Hetzner CX23 (5.99 euros per month, VAT extra) | 4 GB | 71.88 euros | 143.76 euros | 287.52 euros |
Sources: the Hostinger VPS page, the DigitalOcean Droplet pricing page and the Hetzner Cloud pages (checked 14 November 2026). We worked out the totals ourselves. Hostinger 48 months is $155.76 for the first 24 months plus 24 times the renewal price. The other totals assume the price stays the same.
Hetzner lists the CX23 for 5.99 euros, but its page said the product was currently unavailable when we checked. Check stock first. DigitalOcean has a 1 GiB plan at $6 a month (DigitalOcean, 2026). That is enough for a small test app. For the full price picture, read our cheap VPS hosting comparison.
Low-cost Node.js hosting also exists as a managed plan, where the company runs the server for you. Hostinger's Node.js hosting page lists a plan from $2.79 a month on a 48-month term that renews at $16.99 a month. We did not check that plan's limits, so read them before you compare it with a VPS.
How to deploy node js application on Hostinger VPS
You follow the same six steps as above. The steps do not change on Hostinger. Choose a plain Ubuntu image when you set up the server, so the commands in this guide match.
Hostinger's VPS page lists an "OpenLiteSpeed and Node.js" one-click template. It also lists plain operating systems such as Ubuntu and Debian. A template installs its own web server, so it does not match this Nginx guide.
According to Hostinger's VPS page, KVM 1 has 1 vCPU, 4 GB of RAM and 50 GB of NVMe storage for $6.49 a month. That price needs a 24-month term, and the total is $155.76 up front. KVM 2 has 2 vCPU and 8 GB for $8.79 a month on the same term. The renewal prices are $11.99 and $14.99 a month. Check the renewal price before you buy.
Disclosure: this link is an affiliate link. Tutorsbot may earn a commission if you buy, at no extra cost to you.
Hostinger fits you if you want a lot of RAM for a low first price and you know the app will run for two years. It is the wrong choice if you want to pay month to month, since the offer needs a 24-month term and the money-back guarantee lasts 30 days. DigitalOcean and Hetzner bill by the hour, so you can delete a server when the project ends.
Who should not use a VPS
A VPS is the wrong tool in some cases. You do the security and updates yourself. Think about these options first:
- You do not want to manage a server. Use a managed platform instead.
- Nobody on your team can fix a server at night. A platform that restarts and patches for you is safer.
- Your app gets huge, uneven traffic. A VPS has a fixed size, and scaling needs more work.
- You only need a free test for a few days. A free tier or a short, hourly-billed server costs less.
If you are new to hosting, read what is cloud computing first.
Related hosting guides
Photo: StartupStockPhotos, Pixabay Content License, via Pixabay (https://pixabay.com/photos/startup-meeting-brainstorming-594090/)
Fazlur Rahman






