Guides 15 min read ·
Node.js Hosting in India: Shared, Free or VPS? Prices and a Step-by-Step Setup
Where to host Node.js in India in 2026: cPanel limits, free tiers that sleep, and a VPS set-up with PM2, Nginx, SSL and MongoDB for Express and MERN apps.
Node.js hosting needs a server that keeps your app's process running all the time, because a Node.js app is its own web server. In India you have three practical choices: the "Setup Node.js App" page on a cPanel host (cheap but limited), a free platform such as Render or Railway (fine for demos, but free apps go to sleep), or a Linux VPS where you run Node.js with PM2 behind Nginx. For a production Express API, a MERN app, Socket.IO or a Discord bot, a VPS is the option that never sleeps and doesn't restrict versions, ports or WebSockets.
This guide uses Node.js 26 (the Active LTS line), Express 5.3, PM2 7.1 and Nginx on Ubuntu 24.04 LTS, as of November 2026. For Next.js specifically, see our guide to deploying Next.js on a VPS.
Why does a Node.js app need a long-running process?
On a PHP host, the web server runs your PHP script when a request arrives, and the script ends once the page is sent. Node.js works the other way round: your code is the web server. app.listen(3000) opens a port, and the process has to stay alive to answer anything. If it crashes or the server reboots, the site is down until something starts it again.
That process often holds things in memory too: Socket.IO connections, timers, a queue worker or a bot's connection to Discord. So Node.js hosting needs somewhere the process can run all the time, a process manager that restarts it, and usually Nginx in front for HTTPS.
Where can you host Node.js in India: cPanel, free tiers or a VPS?
| Option | How your app runs | Catches (checked November 2026) |
|---|---|---|
| cPanel shared hosting ("Setup Node.js App") | Phusion Passenger starts it when requests arrive | Idle processes are stopped, CommonJS only, limited Node.js versions, WebSockets doubtful. Details below |
| Render, free web service | A container that spins down when idle | Spins down after 15 minutes without inbound traffic and takes about a minute to wake. Always-on Starter is US$7 a month for 512 MB. No India region (nearest: Singapore) |
| Railway, Free plan | A serverless container | US$1 of usage a month, 0.5 GB RAM per service, sleeps after 5 to 10 minutes without outbound traffic. Always-on Hobby is US$5 a month (about ₹464 at ₹92.7 to the dollar) including US$5 of usage. No India region |
| Vercel, Hobby plan | Your Express app becomes one Vercel Function | 300 seconds at most per invocation, runs in Washington, D.C. unless you change the region, and express.static() is ignored |
| Linux VPS | Your own server, on all the time | You install, secure and update it yourself |
Can you deploy a Node.js app on cPanel shared hosting?
Often, yes. Many cPanel hosts offer "Setup Node.js App", which is CloudLinux's Node.js Selector: you choose a Node.js version, an application root and a startup file, click Run NPM Install, and the web server runs the app through Phusion Passenger. That's enough for a small Express site, but the limits are documented:
- Your app isn't always running. Passenger starts the app when a request arrives, and CloudLinux's documentation says it stops an app that has had no requests for
PassengerPoolIdleTime, 300 seconds by default. Hosts can change that, but timers and in-memory caches stop with the process. - Passenger picks the port. cPanel's guide says Passenger controls the port your app listens on.
- CommonJS only. CloudLinux's documentation says Passenger "cannot load ECMAScript modules" and suggests a
.cjswrapper if your app usesimport. - Limited versions. CloudLinux's list stops at Node.js 24.x, and cPanel's own packages cover 16, 18, 20 and 22, three of them past end-of-life. Neither includes Node.js 26.
- WebSockets are a question for your host. cPanel's guide sets Passenger up as an Apache module. Phusion's tuning guide says its Apache integration "has issues" with server-sent events and recommends Passenger Standalone or the Nginx integration instead, and Passenger's issue "WebSockets don't work on Apache" was still open in November 2026. Socket.IO can fall back to HTTP long polling.
HostEthical's web hosting works a little differently: a Node.js app you deploy from the dashboard runs all the time, and we restart it if it crashes. It still runs on the Node.js version we install for everyone, and every app on the plan shares the plan's memory and CPU, so it suits a small Express site or API next to a PHP site. For a current Node.js release of your choice, your own database server, Socket.IO you control end to end or several busy apps, use a Cloud VPS, where none of these limits apply.
Is free Node.js hosting good enough?
For learning, a portfolio project or a demo, yes. For anything people rely on, the sleep rules are the problem: an API that takes a minute to answer after a quiet spell looks broken, and a bot on Render's free tier gets no inbound requests, so it spins down. Free databases are limited too: Render's free Postgres expires 30 days after creation, and MongoDB Atlas's free cluster holds 0.5 GB and allows 100 operations a second.
Paid managed platforms fix the sleeping and are a fair choice if you'd rather not run a server. You pay in US dollars by card, though, and the bill grows with each service and gigabyte of RAM. Our guide to Vercel alternatives in India compares costs.
Which Node.js version should you run in November 2026?
From the Node.js release page and release schedule:
| Line | Status | Supported until |
|---|---|---|
| Node.js 26 (Lithium) | Active LTS since 28 October 2026 | 30 April 2029 |
| Node.js 24 (Krypton) | Maintenance LTS since 20 October 2026 | 30 April 2028 |
| Node.js 22 (Jod) | Maintenance LTS | 30 April 2027 |
| Node.js 20 (Iron) | End-of-life | Ended 30 April 2026 |
| Node.js 27 | Alpha, not for production | LTS from October 2027 |
Start new projects on Node.js 26, or stay on 24 if a dependency isn't ready. From Node.js 27, releases become annual and every major version becomes LTS.
Skip Ubuntu's own package: on Ubuntu 24.04, apt install nodejs gives you Node.js 18.19.1, a line that reached end-of-life on 30 April 2025. Use NodeSource's repository (system-wide, updated with apt) or nvm (per user, easy to switch versions):
# Option 1: NodeSource (what the steps below use)
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
node -v
# Option 2: nvm, for the current user only
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc
nvm install 26
After a Node.js upgrade, PM2's documentation says to run pm2 unstartup and then pm2 startup again so the boot script uses the new binary. This matters most with nvm, where each version lives in its own folder.
How to deploy a Node.js (Express) app on a VPS, step by step
These steps take an Express API from a Git repository to https://api.example.com on a fresh Ubuntu 24.04 server. First point an A record for the hostname at your server's IP (see DNS records explained).
1. Log in as a non-root user and install the basics
Never run your app as root: a bug in your code or a dependency would then control the whole server. If you followed how to set up a VPS, you already have a sudo user and SSH keys. These examples use a user called deploy:
sudo adduser deploy
sudo usermod -aG sudo deploy
su - deploy
sudo apt update && sudo apt install -y git nginx
Then install Node.js 26 from NodeSource as shown above.
2. Clone the app and install dependencies
git clone https://github.com/your-name/myapi.git ~/myapi
cd ~/myapi
npm ci --omit=dev
npm ci installs exactly what's in package-lock.json and refuses to run without one; --omit=dev skips devDependencies. If the app needs a build step, such as TypeScript, run npm ci, npm run build, then npm prune --omit=dev. For a private repository, use a read-only GitHub deploy key.
3. Put secrets in a .env file that never goes into Git
Add .env to your project's .gitignore, then create the file on the server, readable only by your user:
nano ~/myapi/.env # type lines like the two below, then save
chmod 600 ~/myapi/.env
# example contents of .env
DATABASE_URL=mongodb://myapi:long-random-password@127.0.0.1:27017/myapi
JWT_SECRET=paste-the-output-of-openssl-rand-hex-32
Node.js reads this file itself: process.loadEnvFile() is no longer experimental as of Node.js 24.10 (and 22.21), so you don't need the dotenv package. A minimal server.js:
// server.js: a small Express 5 API
const path = require('node:path');
const express = require('express');
process.loadEnvFile(path.join(__dirname, '.env')); // loads .env into process.env
const app = express();
app.set('trust proxy', 'loopback'); // Nginx on this server passes on the visitor's IP
app.use(express.json());
app.get('/api/health', (req, res) => {
res.json({ ok: true });
});
const port = Number(process.env.PORT) || 3000;
app.listen(port, '127.0.0.1', () => {
console.log(`API listening on 127.0.0.1:${port}`);
});
Listening on 127.0.0.1 means port 3000 can't be reached from the internet even if a firewall rule goes wrong. trust proxy makes req.ip show the real visitor instead of Nginx's 127.0.0.1.
4. Run the app with PM2 and use every CPU core
PM2 restarts the app when it crashes, starts it at boot, keeps its logs and, in cluster mode, runs one copy per CPU core on a single port. Create ~/myapi/ecosystem.config.cjs (the .cjs ending works even if package.json says "type": "module"):
// ecosystem.config.cjs: settings that are safe to commit; secrets stay in .env
module.exports = {
apps: [
{
name: 'myapi',
script: 'server.js',
cwd: '/home/deploy/myapi',
exec_mode: 'cluster',
instances: 'max', // one process per vCPU, so 4 on VPS Starter
max_memory_restart: '400M', // restarts a process that grows past 400 MB
env: {
NODE_ENV: 'production',
PORT: '3000',
},
},
],
};
sudo npm install -g pm2 # with nvm, leave out sudo
cd ~/myapi
pm2 start ecosystem.config.cjs
pm2 status # mode, CPU and memory of each process
pm2 logs myapi # live logs; Ctrl+C to stop watching
pm2 startup # prints a sudo command: copy it and run it once
pm2 save # remembers these apps for the next boot
pm2 install pm2-logrotate
pm2 startup prints a sudo env PATH=... command for you to run once; pm2 save then records the running apps so they return after a reboot. pm2-logrotate rotates each log at 10 MB and keeps 30 old files by default. NODE_ENV=production makes Express cache view templates and send shorter error messages (see the Express performance guide). To deploy a new version:
cd ~/myapi && git pull && npm ci --omit=dev && pm2 reload myapi
pm2 reload replaces processes one at a time, so the API stays up. Cluster mode suits apps that keep no state in memory, so store sessions in Redis or your database. Socket.IO's documentation says each client must keep reaching the same process (sticky sessions) unless clients use only the WebSocket transport, and broadcasting across processes needs an adapter such as Redis. Plain PM2 cluster mode doesn't give you sticky sessions (Socket.IO's PM2 page covers the workarounds), so until one core isn't enough, run a Socket.IO app with instances: 1.
If you'd rather deploy from a web dashboard, Coolify and Dokploy install on your own VPS and build from Git; see Coolify vs Dokploy.
5. Put Nginx in front, with WebSocket support
Create /etc/nginx/sites-available/api.example.com:
# outside server {}, and only once on the whole server
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name api.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # lets WebSockets and Socket.IO connect
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo ln -s /etc/nginx/sites-available/api.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Upgrade and Connection are hop-by-hop headers, so the nginx documentation says to pass them explicitly. Its map example, used here, sends Connection: upgrade only when the client asks for a WebSocket. Sites in sites-enabled share it, so define it once even when you add more sites. proxy_http_version 1.1 is needed before nginx 1.29.7 (Ubuntu 24.04 ships 1.24). nginx closes a proxied connection after 60 seconds without data, longer than Socket.IO's default 45-second heartbeat window, so the defaults work together.
6. Turn on HTTPS with Let's Encrypt
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d api.example.com
sudo certbot renew --dry-run
Certbot gets the certificate and adds it to your Nginx config. Let's Encrypt certificates are short-lived, and Ubuntu's certbot package installs a systemd timer that renews them automatically; the dry run confirms renewal works. See what is an SSL certificate for the background.
7. Open only ports 22, 80 and 443
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose
Allow SSH before enabling the firewall, or you'll lock yourself out. Don't open port 3000: visitors reach the app only through Nginx. One trap: Docker's documentation says traffic to published container ports bypasses ufw. If you run MongoDB or Redis in Docker, don't publish the port, or publish it on 127.0.0.1 only.
How to deploy a MERN stack app on a VPS
A MERN app is the Express API above plus a React front end and MongoDB. Don't run the React dev server in production: build static files and let Nginx serve them, with the API on /api.
cd ~/myapp/client
npm ci
npm run build
sudo mkdir -p /var/www/example.com
sudo cp -r dist/. /var/www/example.com/
Vite writes the build to dist/ by default. Building needs devDependencies, hence plain npm ci; you can also build in CI and upload dist. Everything in the build is public, so keep secrets in the API's .env. One Nginx server block serves both:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/example.com; # the React build
index index.html;
location /api/ {
proxy_pass http://127.0.0.1:3000; # no path after the port, so Express sees /api/...
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html; # lets React Router handle deep links
}
}
For Socket.IO, add a location /socket.io/ block with the upgrade headers from step 5 (and the map, if this server doesn't have it yet). For the database:
- MongoDB Atlas. The AWS Mumbai region (ap-south-1) is available, free clusters included, so the data sits close to an Indian VPS. Atlas accepts connections only from its IP access list, so add your VPS's IP.
- MongoDB on the same VPS. MongoDB 9.0 Community has packages for Ubuntu 24.04 (install guide). It listens on 127.0.0.1 by default: keep it that way and never open port 27017. In
mongosh, create an admin user and amyapiuser with thereadWriterole on themyapidatabase (the one in the.envabove), then turn on access control withsecurity.authorization: enabledin/etc/mongod.confand restartmongod.
Can you host a Node.js Discord or Telegram bot the same way?
Yes, and it's simpler: a bot needs no open ports and no Nginx. A Discord bot holds an outbound WebSocket to Discord's Gateway and must keep sending heartbeats; a polling Telegram bot keeps asking Telegram for updates. Both need a process that never stops:
cd ~/discord-bot
npm ci --omit=dev
pm2 start bot.js --name discord-bot
pm2 save
Run bots in fork mode with one instance. With several instances, every copy would log in with the same token, so a Discord bot would reply several times and Telegram would return conflict errors. For a plain systemd set-up, see our guide to hosting a Telegram bot 24/7.
How much server does a Node.js app need?
Each Node.js process has its own memory, so four cluster processes use roughly four times what one does. pm2 status shows each process's memory; check it after a day of real traffic. As a rough rule of thumb, not a measured figure, a small Express API or bot process often stays well under 1 GB, but your code and libraries decide the real number, so measure.
A database on the same server often needs far more. MongoDB's WiredTiger cache defaults to the larger of 50% of (RAM minus 1 GB) or 256 MB, so on an 8 GB server it can take 3.5 GB by itself. On a shared server, cap it with storage.wiredTiger.engineConfig.cacheSizeGB in /etc/mongod.conf, for example 1.5.
That's why VPS Starter's 4 vCPU and 8 GB is roomy for a typical small set-up: an API in cluster mode on four cores, a React front end, a bot or two and MongoDB with its cache capped, with headroom for builds and spikes. Move to VPS Pro or Max for many apps or databases, a large dataset in memory, CPU-heavy work such as image or PDF processing, or big front-end builds on the server.
Running Node.js on HostEthical
On HostEthical, production Node.js apps belong on a Cloud VPS: unmanaged KVM with full root access, a dedicated IPv4 address, SSD storage and Ubuntu 24.04 LTS among the OS choices, built automatically after payment, usually within 5 to 15 minutes. Plans start at ₹860 a month, or about ₹774.17 a month when billed yearly. You pay in rupees by UPI or binance Pay (USDT), with no dollar card charges, and the price stays the same at renewal.
| Plan | vCPU | RAM | Storage | Paid monthly | Paid up front, per month | At renewal |
|---|---|---|---|---|---|---|
| VPS Starter | 4 cores | 8 GB | 100 GB SSD | ₹860 | ₹774.17 (yearly) | Same price |
| VPS Pro | 6 cores | 12 GB | 200 GB SSD | ₹1,170 | ₹1,053.33 (yearly) | Same price |
| VPS Max | 8 cores | 24 GB | 300 GB SSD | ₹2,190 | ₹1,971.67 (yearly) | Same price |
VPS Starter is plenty for most single apps and for several small ones. Choose Mumbai if your users are in India: requests travel a shorter distance and your data stays in India, for ₹380 a month more than Germany. Germany suits users in Europe, internal tools and bots where latency matters less. Our guide to VPS hosting in Mumbai covers the trade-off.
You can also register your domain with us, point its A records at the VPS with our nameservers and DNS editor, and add business email on the same domain.
Frequently asked questions
Can I run a Node.js app on HostEthical web hosting?
Yes, for small apps. Web hosting plans can run one Node.js or Python app per website from the dashboard: we keep it running, restart it if it crashes, and route your domain to it, but it uses the Node.js version we install and shares the plan's memory and CPU. For a Node.js release of your choice, root access or a database of your own, use a Cloud VPS: VPS Starter has 4 vCPU and 8 GB RAM, in Mumbai or Germany.
Should I use PM2 or systemd to run Node.js in production?
Either works, and they combine well. The Express documentation recommends letting the operating system's init system manage your app, and pm2 startup does that by running PM2 itself as a systemd service. PM2 adds cluster mode across CPU cores, zero-downtime reloads and log rotation, which suit web apps; a single bot can run as a plain systemd unit instead.
Can I run several Node.js apps on one VPS?
Yes. Give each app its own port on 127.0.0.1 (3000, 3001 and so on), add each one to PM2 as a separate entry in the ecosystem file, and create one Nginx server block per domain or subdomain that proxies to the right port. Certbot can issue a certificate for each hostname. Keep an eye on total memory with pm2 status, because every app and database shares the same RAM.
Do I need Docker to deploy a Node.js app on a VPS?
No. Node.js, PM2 and Nginx installed directly on Ubuntu are enough for most apps and leave less to learn. Docker helps when you want identical builds on every machine or run several services that need different versions, and self-hosted dashboards such as Coolify and Dokploy use it to deploy from Git.
Why does Nginx show 502 Bad Gateway for my Node.js app?
A 502 means Nginx couldn't get a response from your app. Usually the app has crashed or failed to start (check pm2 status and pm2 logs), it is listening on a different port from the one in proxy_pass, or a missing .env file or variable stops it at start-up. Run curl http://127.0.0.1:3000/api/health on the server: if that fails too, fix the app before touching Nginx.