This is the quickstart tutorial: the fastest path from a fresh Hostinger VPS to a live Node.js app with HTTPS, in about an hour. Minimal theory, maximum doing. If you want the deeper guide covering architecture decisions, security hardening, and production best practices, read our complete Node.js deployment guide.
A Hostinger VPS gives you a blank Linux server you fully control, which makes it a good home for a Node.js app. This guide walks through the whole deployment: installing Node.js, running your app with a process manager, putting Nginx in front of it, and adding free HTTPS.
If you have not chosen a VPS yet, see our Hostinger VPS guide for help picking the right size — a small Node app is comfortable on the entry KVM plan.
What you need
- A Hostinger VPS with Ubuntu 24.04 installed (set during ordering or reinstall from hPanel → VPS → OS).
- SSH access: the root password from your VPS overview page, or an SSH key you added.
- Your app’s code in a Git repository (GitHub, GitLab, or similar), or the files ready to upload.
- A domain pointed at your VPS IP address (an A record), if you want a public URL with HTTPS.
Step 1 — Connect and update the server
Connect over SSH from your terminal:
ssh root@YOUR_VPS_IP
Then update the package lists and install the basics:
apt update && apt upgrade -y
apt install -y curl git ufw
Step 2 — Install Node.js
The simplest reliable method is the NodeSource repository, which gives you a current LTS version:
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs
node -v && npm -v
Both commands should print version numbers. Version 22 is the current LTS line; adjust the setup script number if a newer LTS exists when you read this.
Step 3 — Get your app onto the server
Create a folder for the app and clone your repository:
mkdir -p /var/www/myapp && cd /var/www/myapp
git clone https://github.com/YOU/YOUR-REPO.git .
npm install --production
Test that it starts and listens on its port (commonly 3000):
node server.js
Visit http://YOUR_VPS_IP:3000 in a browser. If your app responds, stop it with Ctrl+C and move on — you do not want to run it in the foreground permanently.
Step 4 — Keep it running with PM2
PM2 is a process manager that restarts your app if it crashes and starts it on boot:
npm install -g pm2
pm2 start server.js --name myapp
pm2 save
pm2 startup
Run the command that pm2 startup prints (it generates a systemd entry). From now on, your app survives reboots and crashes. Useful commands: pm2 logs myapp to read logs, pm2 restart myapp after updates.
Step 5 — Put Nginx in front of it
Visitors should reach your app on port 80/443, not port 3000. Install Nginx and create a reverse proxy:
apt install -y nginx
Create /etc/nginx/sites-available/myapp with:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable it and reload:
ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Now http://yourdomain.com should serve your app (once DNS has propagated).
Step 6 — Firewall and free HTTPS
Open only the ports you need, then add a free Let’s Encrypt certificate:
ufw allow OpenSSH
ufw allow 'Nginx Full'
ufw enable
apt install -y certbot python3-certbot-nginx
certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot configures Nginx for HTTPS automatically and sets up renewal. Your app is now live at https://yourdomain.com.
Step 7 — Deploying updates
For each new version, pull the code and restart:
cd /var/www/myapp
git pull
npm install --production
pm2 restart myapp
For zero-downtime deploys on busier apps, look into PM2’s cluster mode or a CI pipeline later — the flow above is enough to start.
Step 4b — Environment variables and production settings
Real apps need secrets and config that differ between your laptop and the server. Never hardcode them — use environment variables. Create /var/www/myapp/.env (and add .env to .gitignore so it never reaches GitHub):
PORT=3000
NODE_ENV=production
DATABASE_URL=postgres://user:password@localhost:5432/myapp
Tell PM2 to load the file by starting with an ecosystem config instead of a bare command. Create ecosystem.config.js:
module.exports = {
apps: [{
name: "myapp",
script: "server.js",
env: { NODE_ENV: "production" },
env_file: ".env"
}]
};
Then pm2 start ecosystem.config.js && pm2 save. Your code reads process.env.PORT and process.env.DATABASE_URL as usual. Rotate any secret that was ever committed to Git — assume it is compromised.
A minimal Express app to test with
If you do not have an app ready yet, this tiny Express server verifies the whole chain (Node → PM2 → Nginx → HTTPS):
npm init -y && npm install express
cat > server.js <<'EOF'
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.get('/', (req, res) => res.send('Hello from Hostinger VPS'));
app.get('/health', (req, res) => res.json({ ok: true }));
app.listen(port, () => console.log('Listening on ' + port));
EOF
Start it with PM2, point Nginx at it, and a /health endpoint gives you something for uptime monitors to check later.
Keeping the server healthy over time
A deployed app is not a finished job. Enable unattended security upgrades (apt install unattended-upgrades) so the OS patches itself, check pm2 logs weekly for errors you have not noticed, and set up at least one external uptime monitor hitting your /health endpoint. Disk space deserves attention too: Node apps accumulate npm caches and log files, so a monthly df -h glance prevents the classic “server full at 2 a.m.” incident. These five-minute habits are what separate a demo deploy from a production one.
Frequently asked questions
Do I need a managed VPS to run Node.js?
No. Hostinger’s VPS plans are unmanaged, which is fine for Node.js — this guide covers everything the server needs. Managed hosting would cost more and give you less control over the Node version.
Which Node.js version should I install?
Use the current LTS (long-term support) version unless your app’s dependencies require something specific. LTS versions get security updates the longest, which matters on a public server.
Can I host multiple Node apps on one VPS?
Yes. Run each app on its own port with its own PM2 process name, then add one Nginx server block per domain pointing at the right port. Watch total RAM usage — that is usually the limit, not CPU.
What if my app needs a database?
Install PostgreSQL or MySQL on the same VPS for small projects (apt install postgresql), or use a managed database for anything serious. Keep database credentials in environment variables, never in your Git repository.
