If you’ve built a Node.js app (like an API, backend, or dashboard) and want it to run live on your own Hostinger VPS, this guide walks you through everything — from setting up the server to making your domain live with SSL (https).
Let’s get started 👇
🖥️ Step 1: Connect to Your VPS
Once you buy your VPS, Hostinger gives you:
- A public IP address
- A root username
- A password
On your laptop or desktop, open Terminal (Mac/Linux) or PowerShell (Windows) and connect:
Example:
That’s you entering your new remote computer 🚀
Step 2: Create a New User (for safety)
It’s best not to work directly as “root”. Create a normal user:
Now you can log in using that user:
This keeps your server more secure.
⚙️ Step 3: Install Node.js and PM2
We’ll use nvm (Node Version Manager) — it’s the safest way to install Node.js.
Now Node.js is installed. Check it:
Then install PM2 — a tool that keeps your Node.js app running forever, even if the server restarts.
Step 4: Get Your Project on the Server
You can either upload files via Git, FTP, or ZIP.
Easiest way:
If your project uses environment variables (like database URL, API keys), create a .env file:
Step 5: Test if Your App Works
Before setting up anything fancy, make sure your app runs:
(Replace server.js with your app’s main file if it’s different.)
If it prints something like Server running on port 4001, that’s great! 🎉
Press Ctrl + C to stop it.
Step 6: Keep It Running Forever (Using PM2)
Now we’ll use PM2 to keep your app alive all the time:
This means:
- Your app will automatically restart if it crashes.
- It will even start after your server reboots.
To check:
Step 7: Install Nginx (To Serve the App on a Domain)
Nginx acts like a “traffic manager” for your server — it receives all requests (like from api.dharmsy.com) and forwards them to your Node app running on port 4001.
Install Nginx:
Then make a config file for your domain:
Paste this inside (change the domain name and port if needed):
Now activate the config:
🔒 Step 8: Add Free SSL (HTTPS) with Let’s Encrypt
Let’s Encrypt gives you free HTTPS for your domain.
Follow the on-screen steps and choose the option to redirect HTTP to HTTPS.
Now your site is secure:
https://api.secure.com works!
Step 9: Update Your App Without Downtime
When you push new code to GitHub, you can update it easily:
That’s it — no downtime, your API updates instantly 🚀
Step 10: Monitor and Manage
See if everything’s okay:
You’ll see CPU usage, memory, uptime, and logs.
Optional — Simple Auto Deploy Script
You can create a small script to update everything in one command:
Paste:-
Then make it executable:
💡 Bonus Tips
- Use one VPS to host multiple apps (just change ports & Nginx configs)
- Use UFW firewall to block unwanted ports:
- Always run pm2 save after starting your apps
- You can check if SSL auto-renew works:

