August 26, 2026 · by Alex M.
Node.js has become one of the most popular runtime environments for server-side development — from REST APIs and real-time applications to CLI tools and microservices. If you have a SSD VPS and want to run Node.js in production, this guide walks you through every step of the process.
Shared hosting is great for WordPress sites or classic PHP applications. However, Node.js requires its own persistent process, open ports and full control over the runtime environment — things that shared hosting cPanel doesn't natively support.
With an NVMe VPS, you get:
- Full root access — install any Node.js version you need
- Persistent processes — your app runs continuously via PM2 or systemd
- Predictable performance — no noisy neighbours
- Complete control over ports, firewall and configuration
For this guide you will need:
- A VPS running Ubuntu 22.04 or Debian 12 (recommended)
- SSH access with root or sudo privileges
- Basic knowledge of the Linux command line
If you don't have a server yet, you can order an SSD VPS or a 1C VPS — affordable entry points for any new project.
NVM lets you install and switch between multiple Node.js versions without conflicts — the ideal approach for production environments.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Reload your shell configuration:
export NVM_DIR="$HOME/.nvm"
source ~/.bashrc
Verify the installation:
nvm --version
# output: 0.39.7
nvm install --lts
nvm use --lts
nvm alias default 'lts/*'
Check the installed versions:
node --version
# v20.x.x
npm --version
# 10.x.x
If you prefer a system-wide installation available to all users, use the official NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
This method is handy when using server management services where you need a standardised deployment across multiple environments.
To test the environment, let's create a simple HTTP server:
mkdir ~/myapp && cd ~/myapp
nano app.js
Content of app.js:
const http = require('http');
const hostname = '0.0.0.0';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello from CliqHost VPS!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Start the application:
node app.js
Open your browser and navigate to http://YOUR_VPS_IP:3000 — you should see the welcome message.
In a production environment, your application must run continuously and restart automatically after a crash or server reboot. PM2 is the industry-standard solution.
npm install -g pm2
cd ~/myapp
pm2 start app.js --name "myapp"
pm2 startup
# Copy and execute the displayed command (with sudo)
pm2 save
pm2 status # check process status
pm2 logs myapp # view application logs
pm2 restart myapp # restart the app
pm2 stop myapp # stop the app
pm2 delete myapp # remove from PM2 list
Your Node.js app listens on port 3000, but users access the site on ports 80/443. We configure Nginx to forward traffic correctly.
sudo apt update
sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/myapp
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;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
No modern site should run without HTTPS. Install Certbot for a free Let's Encrypt certificate:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
If you need a commercial SSL certificate with extended validation, CliqHost provides SSL certificates for all project types.
Make sure necessary ports are open and port 3000 (internal) is not directly exposed to the internet:
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw deny 3000
sudo ufw enable
sudo ufw status
Never hardcode credentials directly in your code. Use environment variables instead:
npm install dotenv
Create a .env file:
PORT=3000
DB_HOST=localhost
DB_USER=admin
DB_PASS=your_secret_password
NODE_ENV=production
At the top of app.js, add:
require('dotenv').config();
const port = process.env.PORT || 3000;
Important: Add .env to .gitignore to prevent sensitive data from being exposed.
PM2 stores application logs in ~/.pm2/logs/. View logs in real time:
pm2 logs myapp --lines 100
For deeper server resource monitoring, explore the articles on the CliqHost blog where you'll find guides on tracking CPU, RAM and disk usage on Linux.
npm audit fix)pm2 start app.js -i max --name "myapp-cluster"
Installing and configuring Node.js on a Linux VPS is straightforward when you follow the right steps. NVM gives you flexible version management, PM2 guarantees continuous application availability, and the Nginx + SSL combination completes a solid, secure production setup.
For the best performance, an NVMe VPS with ultra-fast storage makes a real difference when your Node.js application needs to handle tens or hundreds of concurrent requests. If you'd rather leave server administration to the experts, our server management services are here for you. Contact the CliqHost team and let's build something great together.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."