page-banner-shape-1
page-banner-shape-2

Node.js Application Deployment on Linux: Complete Step-by-Step Guide for 2026

  • Tanuj Chugh
  • June 12, 2026
Node.js hosting

Node.js Application Deployment on Linux: Complete Step-by-Step Guide for 2026

Node.js Application

Deploying a Node.js application to a Linux server is a foundational skill for every modern developer — and in 2026, the deployment landscape has evolved significantly. Node.js 24 is now the current Active LTS release (the recommended version for all new production deployments), Node.js 26 was released in May 2026 and enters LTS in October 2026, and containerised Node.js application deployment via Docker has become the default approach for teams that need portable, reproducible production environments. Whether you are deploying a REST API, a real-time WebSocket application, a Next.js server, or a microservices backend, getting your Node.js application live on Linux — with process management, reverse proxy configuration, SSL, and monitoring properly set up — requires following the right steps in the right order.

Linux is the OS of choice for Node.js application hosting because it is stable, resource-efficient, open-source, and natively compatible with every major cloud provider: AWS, Google Cloud, Microsoft Azure, Akamai, and CloudMinister’s India-based VPS infrastructure. In this complete 2026 guide, we cover every step from preparing your Node.js application for production through to SSL, CI/CD automation, Docker containerisation, and OpenTelemetry-based observability — so your deployment is not just running, but production-hardened and maintainable.

WHAT YOU WILL LEARN:

• How to prepare your Node.js application for production on Linux in 2026
• How to install Node.js 24 LTS (the current recommended version)
• How to set up PM2 process management for your Node.js application
• How to configure Nginx as a reverse proxy
• How to secure your Node.js application with Let’s Encrypt SSL
• How to automate deployment with GitHub Actions CI/CD
• How to containerise your Node.js application with Docker
• How to monitor your Node.js application with PM2 and OpenTelemetry

Step 1 — Prepare Your Node.js Application for Production

Before deploying your Node.js application to a Linux server, your codebase must be production-ready. A Node.js application that works perfectly on localhost often fails in production due to missing environment variable handling, development-only dependencies left in the bundle, or unhandled promise rejections that crash the process silently. Taking 30 minutes to properly prepare your Node.js application before deployment saves hours of debugging after deployment.

Production Readiness Checklist for Your Node.js Application

Before deploying, verify your Node.js application meets these production requirements:

• Remove all console.log() debug statements — use a structured logger (Winston or Pino) that writes to files in production.
• Handle all unhandled promise rejections with process.on(‘unhandledRejection’) to prevent silent crashes.
• Implement graceful shutdown handling for SIGTERM and SIGINT signals — critical for zero-downtime PM2 restarts and Docker container stops.
• Move all sensitive configuration (API keys, database URLs, JWT secrets) to environment variables using a .env file with the dotenv package.
• Run npm audit to identify and fix security vulnerabilities in your Node.js application dependencies before deployment.
• Specify the Node.js version your application requires in package.json engines field: “engines”: { “node”: “>=24.0.0” }

Environment Variables Setup

Create a  .env  file for your Node.js application:

NODE_ENV=production
PORT=3000
DB_URL=mongodb://localhost:27017/mydb
JWT_SECRET=your_secret_here

⚠️Never commit  .env  to  Git.  Add it to  .gitignore  immediately.

package.json  Production Scripts

"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"test": "jest"
}

Run: npm install –omit=dev
(This replaces the deprecated –production flag in Node.js 24+)

Setting Up a Linux Server for Your Node.js Application

The server you choose for your Node.js application will directly determine its performance, availability, and cost. For most Node.js application deployments in 2026, a Linux VPS (Virtual Private Server) is the optimal starting point — providing dedicated resources, full root access, and complete control over the server environment at a predictable monthly cost.

Choosing Your Operating System (2026 Recommendations)

For a Node.js application on Linux in 2026, use one of these supported, actively maintained OS options:

• Ubuntu 24.04 LTS  — the current Ubuntu LTS release, supported until April 2029. Most Node.js deployment tools and the NodeSource repository are optimised for Ubuntu. Minimum 1 GB RAM for small Node.js applications, 2–4 GB for production workloads.
• Ubuntu 22.04 LTS — still supported until April 2027. Suitable if you have existing infrastructure on 22.04.
• Debian 12 (Bookworm) — stable, minimal, excellent for production servers.
• AlmaLinux 9 or Rocky Linux 9 — the recommended CentOS replacements for RHEL-compatible environments.

⚠️ Do NOT use CentOS: CentOS 7 reached End-of-Life June 30, 2024. CentOS 8 reached EOL December 2021. Both are unsupported and receive no security patches.

Hosting Options for Your Node.js Application

Hosting Type Best For Approx. India Price Node.js App Suitability
Shared Hosting Static sites, WordPress ₹99–₹299/mo ❌ Not suitable
Linux VPS APIs, apps, SMB production ₹699–₹3,000/mo ✅ Recommended
Dedicated Server High-traffic production ₹5,000+/mo ✅ Enterprise scale
Cloud (AWS/Azure) Variable traffic, global Pay-per-use ✅ Enterprise/startup

Why Choose CloudMinister for Your Node.js Application

CloudMinister provides Linux VPS hosting specifically optimised for Node.js application deployment from Indian data centres in Jaipur and Noida — with sub-50ms latency for users across India, plans starting from ₹699/month, Node.js 24 LTS pre-configured on request, SSD NVMe storage, and 24/7 IST-based technical support. 

Remove the two inline CTA images that currently appear in this section.

Connecting to the Server via SSH

ssh -i ~/.ssh/your_key.pem ubuntu@your-server-ip

Use SSH key authentication — never password authentication for production servers. Generate an SSH key pair if needed:
ssh-keygen -t ed25519 -C “[email protected]”

Chat with us

Step 3 — Installing Node.js 24 LTS and Dependencies for Your Node.js Application

Installing the correct Node.js version is the most important technical decision you make when setting up your Node.js application server. As of June 2026, the Node.js LTS landscape is: Node.js 24 = Active LTS (recommended for all new production deployments), Node.js 22 = Maintenance LTS (supported until April 2027), Node.js 20 = End-of-Life (April 30, 2026 — do not use for new deployments), Node.js 26 = Current (not yet LTS — enters LTS October 2026, use for testing only). Always use Node.js 24 for new Node.js application production deployments in 2026.

Update System First

sudo apt update && sudo apt upgrade -y

Installing Node.js 24 LTS via NodeSource (Ubuntu/Debian)

Install NodeSource repository for Node.js 24 LTS
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash –

Install Node.js and npm
sudo apt install -y nodejs

Verify installation
node -v # Should output v24.x.x
npm -v # Should output 10.x.x or higher

Installing Node.js 24 LTS via AlmaLinux/Rocky Linux (replaces CentOS)

Add NodeSource repo for AlmaLinux 9 / Rocky Linux 9
curl -fsSL https://rpm.nodesource.com/setup_24.x | sudo bash –

Install Node.js
sudo dnf install -y nodejs

Verify
node -v && npm -v

Using NVM for Node.js Version Management (recommended for developers)

nvm (Node Version Manager) is the recommended way to manage Node.js versions when working across multiple Node.js application projects:

Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc

Install and use Node.js 24 LTS
nvm install 24
nvm use 24
nvm alias default 24

Verify
node -v

Installing PM2 and Nginx

Install PM2 globally (process manager for your Node.js application)
sudo npm install -g pm2

Install Nginx (reverse proxy)
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx

Step 4 — Deploying Your Node.js Application to the Linux Server

With your Linux server configured and Node.js 24 LTS installed, you are ready to transfer and start your Node.js application. There are two primary methods for getting your Node.js application files onto the server: SCP (for one-time transfers) or Git (for ongoing deployments where you push code updates and pull them on the server).

Method 1 — Transfer Files via SCP (one-time)

Transfer your Node.js application directory to the server
scp -r /path/to/your/app ubuntu@your-server-ip:/var/www/myapp

Method 2 — Clone from Git (recommended for production)

On the server, clone your repository
mkdir -p /var/www && cd /var/www
git clone https://github.com/your-username/your-repo.git myapp
cd myapp

Install production dependencies only
npm install –omit=dev

Copy your .env file (do NOT include .env in Git)
Transfer it separately via SCP:
scp .env ubuntu@your-server-ip:/var/www/myapp/.env

Starting Your Node.js Application With PM2

PM2 is the production-standard process manager for Node.js application deployment on Linux. It keeps your Node.js application running after terminal disconnection, auto-restarts after crashes, and enables zero-downtime restarts.

Start your Node.js application with PM2
pm2 start server.js –name “myapp”

Or use an ecosystem file for complex Node.js applications:
pm2 start ecosystem.config.js

Enable PM2 to start on server reboot
pm2 startup # Run the command it outputs as root
pm2 save # Save current process list

Useful PM2 commands for your Node.js application:
pm2 status # View all running processes
pm2 logs myapp # View application logs
pm2 restart myapp # Restart the application
pm2 reload myapp # Zero-downtime reload (for clustered apps)

Step 5 — Configuring Nginx as a Reverse Proxy for Your Node.js Application

Nginx sits between the internet and your Node.js application — receiving all incoming HTTP/HTTPS requests and forwarding them to your application running on localhost:3000. This architecture is essential for every production Node.js application because it enables SSL termination, load balancing, static file serving, gzip compression, and security headers — all handled by Nginx before requests even reach your Node.js application code.

Create Nginx Configuration for Your Node.js Application

sudo nano /etc/nginx/sites-available/myapp

Paste the following configuration:

server {
listen 80;
server_name yourdomain.com www.yourdomain.com;

# Gzip compression for better Node.js application performance
gzip on;
gzip_types text/plain application/json application/javascript text/css;

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_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 90s;
}
}

Enable and Test the Configuration

Enable the site
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/

Test Nginx configuration — always do this before restarting
sudo nginx -t

If test passes, restart Nginx
sudo systemctl restart nginx

Your Node.js application is now accessible at http://yourdomain.com

Contact us

Step 6 — Securing Your Node.js Application on Linux

Security is not optional for a production Node.js application — it is the foundation that determines whether your application and your users’ data remain protected in an environment where web-facing servers are continuously probed for vulnerabilities.

UFW Firewall Configuration

Allow only necessary traffic for your Node.js application
sudo ufw allow OpenSSH
sudo ufw allow ‘Nginx Full’
sudo ufw deny 3000 # Block direct access to Node.js application port
sudo ufw enable
sudo ufw status

SSL Certificate with Let’s Encrypt (Certbot)

Install Certbot for Nginx
sudo apt install certbot python3-certbot-nginx -y

Obtain SSL certificate for your domain
sudo certbot –nginx -d yourdomain.com -d www.yourdomain.com

Certbot automatically configures Nginx for HTTPS
Verify auto-renewal works
sudo certbot renew –dry-run

Your Node.js application is now served over HTTPS at https://yourdomain.com

Security Best Practices for Your Node.js Application in 2026

• Run your Node.js application as a non-root user — never run pm2 or node as root.
sudo adduser nodeapp
sudo chown -R nodeapp:nodeapp /var/www/myapp

• Use Helmet.js for HTTP security headers:
npm install helmet
// In your Node.js application:
const helmet = require(‘helmet’);
app.use(helmet());

• Enable automatic OS security updates:
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure unattended-upgrades

• Run npm audit regularly and fix vulnerabilities:
npm audit fix

• Use rate limiting to protect your Node.js application API:
npm install express-rate-limit

Step 7 — Automating Node.js Application Deployment With GitHub Actions CI/CD

Manual deployment — SSH into your server, git pull, pm2 restart — works for small projects but becomes error-prone and slow as your Node.js application grows. CI/CD (Continuous Integration / Continuous Deployment) pipelines automate this entire workflow: every time you push code to your main branch, the pipeline automatically tests your Node.js application, then deploys it to your production server without any manual steps. GitHub Actions is the most widely used CI/CD platform for Node.js application deployment in 2026 — it is free for public repositories and has generous free tier limits for private repositories.

GitHub Actions Workflow for Your Node.js Application

Create this file in your repository: .github/workflows/deploy.yml

name: Deploy Node.js Application

on:
push:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v4
– name: Use Node.js 24
uses: actions/setup-node@v4
with:
node-version: ’24’
cache: ‘npm’
– run: npm ci
– run: npm test

deploy:
needs: test
runs-on: ubuntu-latest
steps:
– name: Deploy Node.js Application via SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /var/www/myapp
git pull origin main
npm install –omit=dev
pm2 reload myapp

Setting Up GitHub Secrets

Go to your GitHub repository → Settings → Secrets and Variables → Actions and add:

• SERVER_IP — your VPS IP address
• SERVER_USER — ubuntu (or your non-root user)
• SSH_PRIVATE_KEY — your private SSH key (cat ~/.ssh/id_ed25519)

This workflow runs tests first, and only deploys your Node.js application to production if tests pass — preventing broken deployments.

Step 8 — Monitoring and Maintaining Your Node.js Application in Production

A deployed Node.js application that is not monitored is a production incident waiting to happen. Memory leaks, CPU spikes, unhandled promise rejections, and database connection exhaustion are all common Node.js application issues that are invisible without proper monitoring — and catastrophic when they hit production at peak traffic. In 2026, production Node.js application monitoring should cover three layers: process health (PM2), application observability (OpenTelemetry), and uptime alerting (external monitoring).

Layer 1 — PM2 Process Monitoring

Real-time monitoring dashboard for your Node.js application
pm2 monit

View logs
pm2 logs myapp –lines 100

Check process status
pm2 status

Restart with zero downtime (recommended over pm2 restart)
pm2 reload myapp

PM2 Cluster Mode — Scale your Node.js application across all CPU cores:
pm2 start server.js –name “myapp” -i max
-i max uses all available CPU cores for your Node.js application

Layer 2 — OpenTelemetry Observability (2026 Standard)

OpenTelemetry (OTel) is the open standard for distributed tracing and observability — recommended by the Node.js core team for production Node.js application monitoring in 2026. It provides distributed tracing so you can track requests across all services in a microservices Node.js application.

Install OpenTelemetry SDK for your Node.js application
npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node

Create instrumentation.js in your Node.js application root:
const { NodeSDK } = require(‘@opentelemetry/sdk-node’);
const { getNodeAutoInstrumentations } = require(‘@opentelemetry/auto-instrumentations-node’);

const sdk = new NodeSDK({
traceExporter: /* your exporter (Jaeger, Grafana Tempo, etc.) */,
instrumentations: [getNodeAutoInstrumentations()]
});

sdk.start();

Start your Node.js application with OpenTelemetry:
node –require ./instrumentation.js server.js

Layer 3 — Uptime & External Monitoring

• UptimeRobot (free) — monitors your Node.js application URL every 5 minutes, alerts by email/SMS when down.
• Grafana + Prometheus — open-source stack for Node.js application metrics, dashboards, and alerting.
• New Relic — commercial APM with deep Node.js application profiling and error tracking.

Memory Monitoring for Your Node.js Application

Track memory usage to detect leaks before they cause OOM crashes:
# Add to your Node.js application (track in logs):
setInterval(() => {
const mem = process.memoryUsage();
console.log(`heapUsed: ${Math.round(mem.heapUsed / 1024 / 1024)}MB`);
}, 30000);

Scaling Your Node.js Application

• Vertical scaling — upgrade your CloudMinister VPS RAM/CPU from the control panel.
• Horizontal scaling — deploy multiple VPS instances behind a load balancer.
• PM2 cluster mode — use all CPU cores on a single server for your Node.js application.

Step 9 — Containerising Your Node.js Application With Docker (2026 Approach)

Docker containerisation has become the standard deployment approach for Node.js application production environments in 2026 — recommended by the Node.js core team for its reproducibility, portability, and isolation benefits. A containerised Node.js application runs identically in development, staging, and production — eliminating the “it works on my machine” problem that plagues traditional VPS deployments. If you are building a new Node.js application in 2026, containerising it from the start is the recommended approach.

Multi-Stage Dockerfile for Your Node.js Application

Create a Dockerfile in your Node.js application root:

Stage 1: Build stage
FROM node:24-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci –omit=dev

Stage 2: Production image
FROM node:24-alpine AS production
WORKDIR /app

Run Node.js application as non-root user
RUN addgroup -S nodeapp && adduser -S nodeapp -G nodeapp
COPY –from=builder /app/node_modules ./node_modules
COPY . .
RUN chown -R nodeapp:nodeapp /app
USER nodeapp

EXPOSE 3000
CMD [“node”, “server.js”]

Build and Run Your Containerised Node.js Application

Build the Docker image for your Node.js application
docker build -t myapp:latest .

Run the Node.js application container
docker run -d \
–name myapp \
-p 3000:3000 \
–env-file .env \
–restart unless-stopped \
myapp:latest

docker-compose for Local Development

Create docker-compose.yml:

version: ‘3.8’
services:
app:
build: .
ports:
– “3000:3000”
env_file: .env
depends_on:
– db
db:
image: mongo:7
volumes:
– mongo_data:/data/db

volumes:
mongo_data:

Start your full Node.js application stack:
docker compose up -d

Conclusion

Deploying a Node.js application to Linux in 2026 involves more than just running node server.js — a production-ready Node.js application needs proper process management (PM2), a reverse proxy (Nginx), SSL/TLS encryption (Let’s Encrypt), automated deployment (GitHub Actions), and observability (PM2 + OpenTelemetry). By following the 9 steps in this guide — using Node.js 24 Active LTS, Ubuntu 24.04, and the current security and monitoring best practices — your Node.js application is built on a foundation that is secure, scalable, and maintainable in 2026 and beyond.

If you want to skip the server configuration overhead entirely, CloudMinister offers managed Linux VPS hosting specifically optimised for Node.js application deployment — with pre-configured Node.js 24 LTS environments, 24/7 technical support, NVMe SSD storage, and data centres in Jaipur and Noida for sub-50ms latency across India. Our team can help you deploy your Node.js application from code to production in hours, not days.

Frequently Asked Questions


Q: Which Node.js version should I use for my Node.js application in production in 2026?

A: Use Node.js 24 — the current Active LTS (Long-Term Support) release as of June 2026. Node.js 24 is recommended for all new production Node.js application deployments and will receive bug fixes and security patches until April 2028. Node.js 22 is in Maintenance LTS (supported until April 2027) and is safe for existing applications. Node.js 20 reached End-of-Life on April 30, 2026 — migrate away from it immediately. Node.js 26 is available as Current but does not enter LTS until October 2026.


Q: How do I keep my Node.js application running after closing the terminal?

A: Use PM2, the production-standard process manager for Node.js applications on Linux. PM2 keeps your Node.js application running continuously, auto-restarts it on crashes, and survives server reboots. Here are the correct commands:

pm2 start app.js –name “myapp”
pm2 save
pm2 startup

The pm2 startup command generates a systemd service — run the command it outputs as root to enable PM2 on boot.


Q: How do I configure Nginx as a reverse proxy for my Node.js application?

A: Create an Nginx server block that forwards requests from port 80/443 to your Node.js application running on localhost:3000. See the full Nginx configuration in Step 5 of this guide. After creating the config, enable it with: sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/ then test with sudo nginx -t and restart with sudo systemctl restart nginx.


Q: How do I automate deployment of my Node.js application with CI/CD?

A: Use GitHub Actions. Create a .github/workflows/deploy.yml file that runs your tests and then deploys to your server via SSH on every push to main. The correct PM2 command for zero-downtime deployment is:

pm2 reload myapp

(Not pm2 restart — reload does a graceful rolling restart with zero downtime.) See the complete GitHub Actions workflow in Step 7 of this guide.


Q: How do I secure my Node.js application with HTTPS?

A: Use Let’s Encrypt with Certbot for free SSL certificates. Install Certbot with sudo apt install certbot python3-certbot-nginx -y then run sudo certbot –nginx -d yourdomain.com. Certbot automatically configures Nginx for HTTPS and sets up auto-renewal via a systemd timer. Additionally, block direct access to your Node.js application port (3000) with: sudo ufw deny 3000 — so all traffic must go through Nginx.


Q: Should I use Docker to deploy my Node.js application in 2026?

A: Yes — Docker containerisation is the recommended deployment approach for Node.js applications in 2026. It provides environment consistency (same behaviour in dev, staging, and production), easier scaling, and portable deployments. Use the node:24-alpine base image with a multi-stage build to minimise image size. For teams already familiar with PM2 + Nginx on VPS, the traditional approach remains completely valid — Docker adds the most value when you need portability across environments or are deploying to container orchestration platforms like Kubernetes.


Q: How do I monitor my Node.js application in production?

A: Use a three-layer approach:

(1) PM2 for process health — pm2 monit gives real-time CPU and memory dashboards.

(2) OpenTelemetry for application observability — instrument your Node.js application with the OTel SDK for distributed tracing across microservices.

(3) External uptime monitoring — UptimeRobot (free) alerts you when your Node.js application URL stops responding. Track memory usage with process.memoryUsage() to detect leaks early.


Q: What is the best Linux VPS for hosting a Node.js application in India?

A: For deploying a Node.js application in India, look for a Linux VPS with at least 1 GB RAM (2 GB recommended for production), NVMe SSD storage, Ubuntu 24.04 LTS availability, and India-based data centres for low latency. CloudMinister provides Linux VPS plans optimised for Node.js application hosting from Jaipur and Noida data centres — with plans starting from ₹699/month, Node.js 24 LTS available, 24/7 IST-based support, and free migration from your existing provider.

Tanuj Chugh

He is the CEO and Founder with over a decade of experience in cloud infrastructure, DevOps, and server optimization. With a strong vision and hands-on leadership approach, he has built scalable, secure, and high-performance cloud solutions trusted by businesses across industries.

https://cloudminister.com/
Call Now Button