For our Blog Visitor only Get Additional 3 Month Free + 10% OFF on TriAnnual Plan YSBLOG10
Grab the Deal

How to Deploy Node JS App on Ubuntu VPS 2026: Complete Guide

Deploying a Node.js application on an Ubuntu VPS helps create a secure, scalable, and high-performance production environment for APIs, SaaS platforms, backend systems, dashboards, and modern web applications that require stable uptime and better server flexibility.

Unlike localhost development, production deployment requires proper server configuration, HTTPS security, firewall protection, reverse proxy setup, process management, and performance optimization so the Node.js application can handle real users and continuous traffic efficiently.

In this complete guide, you will learn how to deploy a Node JS app on Ubuntu VPS step by step, including Node.js installation, PM2 configuration, Nginx setup, SSL security, firewall management, deployment optimization, and common troubleshooting methods used in 2026.


What Is Node JS App Deployment?

Node.js app deployment is the process of taking your application from a local development environment and making it available on a live server so real users can access it through a website, domain name, mobile app, or API endpoint.

When developers build a Node.js application, it usually runs locally on their computer using commands like:

npm start

or:

node app.js

At this stage, the application is only accessible on localhost, which means nobody outside the developer’s machine can use it.

Deployment changes that.

Once deployed to a production server such as an Ubuntu VPS, the Node.js application becomes publicly accessible online. This allows visitors, customers, APIs, or connected services to interact with the application securely and reliably from anywhere.

Modern Node.js deployment involves much more than simply starting the application. A production environment must be configured for performance, uptime, scalability, and security so the app can handle real-world traffic without crashing or exposing vulnerabilities.

A standard Node.js production setup usually includes the following components:

Deployment ComponentPurpose
Ubuntu VPSHosts the Node.js application
Node.js RuntimeExecutes JavaScript on the server
PM2Keeps the application running continuously
NginxActs as a reverse proxy and traffic handler
SSL CertificateEnables secure HTTPS connections
Domain NameAllows users to access the application easily
FirewallProtects server ports and unauthorized access

Modern Node.js deployment mainly focuses on:

  • Stable application uptime
  • Better server performance
  • Secure HTTPS communication
  • Automatic crash recovery
  • Scalability for growing traffic
  • Efficient resource management
  • Error logging and monitoring
  • Safer production environments

Today, Node.js is widely used for production applications because of its fast asynchronous architecture and efficient runtime. It powers many modern platforms including:

  • REST APIs
  • SaaS applications
  • Real-time chat systems
  • Streaming platforms
  • Dashboards
  • Automation tools
  • Backend services
  • Microservices architectures

This is why deploying Node.js correctly on an Ubuntu VPS is important for developers who want a fast, secure, and reliable production environment.


Why Ubuntu VPS Is Better for Node JS Hosting

Ubuntu VPS hosting remains one of the most reliable choices for Node.js deployment because it provides dedicated resources, full root access, stable Linux performance, better scalability, and excellent compatibility with modern development tools used for production applications.

Main Benefits of Ubuntu VPS for Node.js

FeatureBenefit
Full Root AccessComplete control over server configuration
Dedicated ResourcesBetter performance and faster response times
Ubuntu Package SystemEasy installation and software management
PM2 CompatibilityStable Node.js process management
Nginx SupportBetter reverse proxy and traffic handling
SSH AccessSecure remote server management
ScalabilityUpgrade RAM, CPU, and storage anytime
Better Security ControlConfigure firewall and server protection manually

Ubuntu VPS hosting is especially useful for:\n\n- Express.js applications

  • REST APIs
  • Next.js backend hosting
  • WebSocket applications
  • SaaS platforms
  • Admin dashboards
  • Real-time systems
  • Automation tools
  • Backend microservices

Ubuntu is also beginner-friendly because it includes strong documentation, reliable package management, regular security updates, and a large developer community that makes troubleshooting and server management much easier for developers.

Ubuntu VPS vs Shared Hosting for Node.js

FeatureUbuntu VPSShared Hosting
Root AccessYesNo
Custom Node.js ConfigurationFull ControlVery Limited
PM2 SupportFully SupportedRarely Available
PerformanceHighMedium
ScalabilityFlexibleRestricted
Server ControlCompleteMinimal
Reverse Proxy SupportYesLimited
Custom Port AccessAllowedOften Restricted
Production OptimizationAdvancedBasic

Shared hosting may work for small websites, but Ubuntu VPS provides better performance, stronger security, scalable infrastructure, and full deployment flexibility, making it a much better solution for modern production Node.js applications.


Ubuntu 22.04 LTS remains one of the most stable and widely recommended Linux distributions for Node.js deployment because it provides long-term support, reliable security updates, strong software compatibility, and a production-ready environment for modern applications.

The term LTS stands for Long-Term Support, which means:\n\n- Long security support cycle

  • Stable package updates
  • Better compatibility
  • Fewer breaking changes
  • Reliable production environment

Many developers prefer Ubuntu 22.04 because most Node.js deployment tools and server technologies are already optimized for Ubuntu-based systems, making installation, configuration, and long-term server management much easier.

Ubuntu 22.04 Advantages

  • Stable Linux kernel
  • Strong security updates
  • Easy package management
  • Excellent community support
  • Better Docker compatibility
  • Large documentation ecosystem
  • Reliable Node.js support

Ubuntu 22.04 also works smoothly with:\n\n- PM2

  • Nginx
  • Certbot
  • Git
  • Docker
  • Redis
  • MongoDB
  • PostgreSQL

This combination creates a flexible and production-ready deployment environment suitable for modern Node.js applications, APIs, SaaS platforms, dashboards, and backend services in 2026.


Why Use YouStable Ubuntu VPS Hosting for Node JS Apps

Choosing reliable VPS hosting is important because server quality directly affects Node.js application performance, uptime, scalability, security, and overall user experience, especially when running production applications that require stable resources and consistent server availability.

YouStable Ubuntu VPS Hosting provides Ubuntu VPS plans suitable for Node.js applications ranging from beginner projects and REST APIs to scalable production deployments that require better server control and flexible resource management.

Features Useful for Node.js Hosting

FeatureBenefit for Node.js Apps
NVMe SSD StorageFaster app loading
Full Root AccessComplete deployment control
Ubuntu VPS TemplatesEasy setup
Scalable ResourcesHandle growing traffic
DDoS ProtectionBetter security
Multiple Server LocationsLower latency
High Uptime InfrastructureReliable production hosting
Project TypeRecommended RAMCPUStorage
Small Node.js App2 GB1 vCPU50 GB SSD
Medium API Project4 GB2 vCPU100 GB SSD
Large Production App8 GB+4 vCPU+200 GB SSD

For beginners learning Node.js deployment, a small Ubuntu VPS plan is usually enough, while growing applications and production environments may require higher RAM, additional CPU cores, and larger SSD storage for better performance and scalability.


Things to Prepare Before Deploying Your Node JS App

Before deploying your Node.js application on Ubuntu VPS, it is important to prepare the required server access, deployment tools, project files, and software properly to avoid installation issues and make the entire deployment process smoother and more efficient.

Required Items

Keep these important deployment requirements ready before starting the Node.js installation and Ubuntu VPS configuration process.

  • Ubuntu VPS server
  • SSH access credentials
  • Domain name
  • Node.js application files
  • Git repository access
  • Basic Linux terminal knowledge
  • Stable internet connection

These tools help simplify Node.js deployment, server management, file transfers, project editing, and application testing on Ubuntu VPS.

ToolPurposeWhy It Is Important
Terminal / PowerShellSSH server accessConnects your local system to the Ubuntu VPS
GitProject managementHelps clone and manage Node.js project files
VS CodeCode editingMakes server and project editing easier
FileZillaFile transferUploads project files to the VPS server
BrowserApplication testingVerifies the deployed Node.js application
NPMPackage managementInstalls Node.js project dependencies

How to Deploy Node JS App on Ubuntu VPS Step by Step

Deploying a Node.js application on Ubuntu VPS involves configuring the server properly, installing required software, setting up security, and optimizing the environment for stable production performance, scalability, HTTPS support, and long-term application management.

Step 1: Connect to Ubuntu VPS Using SSH

SSH (Secure Shell) allows you to securely access and manage your Ubuntu VPS remotely from your local computer. It is commonly used for installing software, uploading project files, configuring services, managing Node.js applications, and performing server administration tasks through the terminal.

After purchasing an Ubuntu VPS, your hosting provider will usually send the following server details:

  • VPS public IP address
  • Root username or custom SSH user
  • Password or SSH private key
  • SSH port number (default is 22)

Connect to Ubuntu VPS Using SSH

Open your terminal on Linux or macOS, or use PowerShell/Windows Terminal on Windows, then run the following command:

ssh root@your_server_ip

Example:

ssh root@192.168.1.10

If your VPS uses a custom SSH port, use:

ssh -p 2222 root@your_server_ip

During the first connection, Ubuntu may display a security message like this:

The authenticity of host '192.168.1.10' can't be established.

Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type:

yes

Then press Enter.

After that, enter your VPS password when prompted:

root@192.168.1.10's password:

Once authentication is successful, you will gain terminal access to your Ubuntu VPS server and can begin the Node.js deployment process.

Step 2: Update Ubuntu Server Packages

Updating Ubuntu packages before deployment helps improve security, system stability, package compatibility, and reduces installation issues during Node.js, PM2, Nginx, and SSL configuration.

Updating Ubuntu also helps:

  • Fix security vulnerabilities
  • Install latest package updates
  • Improve package compatibility
  • Reduce deployment issues

Run the following command:

sudo apt update && sudo apt upgrade -y

The update process may take several minutes depending on available package updates and server performance.

Step 3: Install Node JS on Ubuntu VPS

Installing the latest Node.js LTS version helps improve long-term stability, package compatibility, security updates, and production performance for modern Node.js applications hosted on Ubuntu VPS environments.

Install NodeSource Repository

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

Install Node.js

sudo apt install nodejs -y

Verify Node.js Installation\

node -v
npm -v

Expected output example:

v22.x.x
10.x.x

This confirms that Node.js and NPM are installed successfully on the Ubuntu VPS server.

Step 4: Upload Node JS Project Files to Ubuntu VPS

Your Node.js project files must be uploaded to the Ubuntu VPS before installing dependencies and starting the application inside the production server environment.

Method 1: Clone Project From GitHub

Install Git first:

sudo apt install git -y

Clone the repository:

git clone https://github.com/your-repository.git

Move into the project directory:

cd your-project-folder

Method 2: Upload Files Using SFTP

You can also upload project files manually using:

  • FileZilla
  • WinSCP
  • VS Code Remote SSH

Step 5: Install Project Dependencies

Installing project dependencies downloads all required Node.js packages listed inside the package.json file so the application can run correctly on the Ubuntu VPS production environment.

Run the following command inside the project folder:

npm install

The installation process may take several minutes depending on project size and dependency requirements.

Step 6: Start and Test the Node JS Application

Testing the Node.js application manually before configuring PM2 or Nginx helps verify that the application and server environment are working properly without deployment issues.

Start the application manually:

npm start

or:

node app.js

If the application starts successfully, you may see output like:

Server running on port 3000

Open the following URL in your browser:

http://your_server_ip:3000

If the application loads successfully, the deployment setup is working correctly.

Step 7: Install and Configure PM2

PM2 is a production process manager for Node.js applications that helps keep applications online continuously, restart crashed processes automatically, and improve long-term production stability.

PM2 mainly helps with:

  • Keeping applications online continuously
  • Restarting crashed apps automatically
  • Starting apps after server reboot
  • Managing logs easily

Install PM2

sudo npm install -g pm2

Start Node.js App Using PM2

pm2 start app.js

Save PM2 Configuration

pm2 save

Enable PM2 Auto Startup

pm2 startup

PM2 will now manage the Node.js application automatically in the background.

Step 8: Install and Configure Nginx

Nginx works as a reverse proxy server between visitors and your Node.js application, helping improve security, HTTPS support, request handling, and production traffic management.

Nginx mainly helps with:

  • Improving security
  • Handling HTTPS connections
  • Managing domain requests
  • Improving traffic handling
  • Optimizing production performance

Install Nginx

sudo apt install nginx -y

Open Nginx Configuration File

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

Example Nginx Reverse Proxy Configuration

server {
   listen 80;
   server_name 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;
   }
}

Save the file and restart Nginx:

sudo systemctl restart nginx

Step 9: Connect Domain Name to Ubuntu VPS

Connecting a domain name to your Ubuntu VPS allows users to access the Node.js application using a professional website address instead of a raw server IP address.

After configuring Nginx successfully, you must point your domain name to the Ubuntu VPS server through DNS settings so incoming traffic reaches the correct server environment properly.

Go to your domain registrar dashboard and update the DNS A record by pointing your domain to the public IP address of your Ubuntu VPS server.

Example DNS Configuration

Record TypeHostValue
A Record@Your VPS IP Address
A RecordwwwYour VPS IP Address

Example:

A Record → 192.168.1.10

You can verify whether the domain is pointing correctly to your VPS server using the following command:

ping yourdomain.com

DNS propagation may take several minutes or several hours depending on your domain provider and global DNS cache updates across internet networks.

After propagation finishes successfully, your domain should load the Node.js application through the configured Nginx reverse proxy running on the Ubuntu VPS server.

Step 10: Enable HTTPS SSL Certificate

HTTPS encryption improves website security, browser trust, SEO rankings, and protects sensitive data transferred between users and the Node.js application hosted on the Ubuntu VPS.

HTTPS mainly helps with:

  • Browser trust
  • SEO rankings
  • Better security
  • User privacy protection

Install Certbot

sudo apt install certbot python3-certbot-nginx -y

Generate SSL Certificate

sudo certbot --nginx

Follow the on-screen instructions carefully to complete the SSL certificate installation process.

After successful installation, your website should open securely using: https://yourdomain.com

Step 11: Configure Ubuntu Firewall

Ubuntu includes UFW firewall support that helps protect the VPS server by controlling incoming traffic and allowing only required ports for Node.js deployment and public website access.

Allow SSH Access

sudo ufw allow OpenSSH

Allow HTTP and HTTPS Traffic

Enable Firewall

sudo ufw enable

Check Firewall Status

sudo ufw status

A properly configured firewall helps improve Ubuntu VPS security and reduces unauthorized server access risks for production Node.js applications.


How to Secure a Node JS App on Ubuntu VPS

Securing a Node.js application on Ubuntu VPS is extremely important because production servers are constantly exposed to internet traffic, login attempts, malware attacks, unauthorized access attempts, and other security vulnerabilities that can affect application stability and user data.

Security PracticeBenefit
Disable root loginReduces attack risk
Use SSH keysBetter authentication
Keep Ubuntu updatedFixes vulnerabilities
Enable firewallBlocks unwanted traffic
Use HTTPSEncrypts data
Remove unused servicesReduces attack surface

Use Strong Passwords

Using strong passwords helps protect your Ubuntu VPS from brute-force attacks, unauthorized access attempts, and server compromise caused by weak or commonly used login credentials.

Avoid weak passwords like:\n\n- admin123

  • password
  • root123

Use strong passwords that include:\n\n- Uppercase letters

  • Lowercase letters
  • Numbers
  • Special characters
  • Longer password length

Strong password example:\n\n“`text
X7@kL92#vQ!mP4


Common Node JS Deployment Errors and Their Solutions

Node.js deployment errors are common during Ubuntu VPS configuration, especially when working with ports, permissions, Nginx, PM2, or server processes, but most problems can usually be fixed quickly using the correct Linux commands and configuration checks.

Address Already in Use Error

This error usually appears when another application or process is already using the same port required by your Node.js application, preventing the server from starting properly on Ubuntu VPS.

Find the Running Process

sudo lsof -i :3000

Kill the Process

kill -9 PID

Replace PID with the actual process ID shown in the terminal output.

Nginx 502 Bad Gateway Error

The Nginx 502 Bad Gateway error usually means that Nginx cannot properly communicate with the Node.js application running behind the reverse proxy configuration.

This often happens because:\n\n- Node.js app is offline

  • Wrong proxy port is configured
  • PM2 process stopped unexpectedly

Restart PM2 Applications

pm2 restart all

Restart Nginx Service

sudo systemctl restart nginx

After restarting both services, refresh the website and verify the Nginx reverse proxy configuration again.

Permission Denied Error

Permission denied errors usually occur when project files or folders do not have the correct ownership or Linux permissions required for Node.js applications and deployment commands.

Fix File Ownership

sudo chown -R $USER:$USER your-project-folder

This command changes the project ownership to the current Ubuntu user and helps resolve many common deployment permission issues.


How to Update a Node JS App After Deployment

Updating a Node.js application properly helps apply new features, security patches, bug fixes, and performance improvements without breaking the production environment running on your Ubuntu VPS server.

Pull Latest Changes

Pull the latest project updates from your Git repository before restarting the Node.js application on the production server.

git pull

Install Updated Packages

Install newly added or updated Node.js dependencies required by the latest application version after pulling project changes successfully.

npm install

Restart PM2 Processes

Restart the PM2 process manager so the updated Node.js application loads properly with the latest files and configurations.

pm2 restart all

This safely reloads the updated Node.js application without requiring a complete Ubuntu VPS reboot.


Best Practices for Production Node JS Deployment

Following production deployment best practices helps improve Node.js application security, long-term stability, server reliability, scalability, and overall performance while reducing downtime and preventing common production environment issues on Ubuntu VPS servers.

Important Deployment Best Practices

Best PracticePurpose
Use PM2Process management
Use HTTPSSecure traffic
Keep backupsData protection
Monitor logsDetect issues
Update packagesSecurity patches
Use environment variablesProtect secrets
Monitor RAM usageBetter performance

Use Environment Variables

Environment variables help protect sensitive information by keeping private credentials and configuration values outside the main Node.js application source code.

Never hardcode:\n\n- API keys

  • Database passwords
  • Secret tokens

Use environment variables like:\n\n“`env id=”f8n2vk”
PORT=3000
DB_PASSWORD=yourpassword

This improves security, simplifies configuration management, and makes Node.js applications safer for production deployment on Ubuntu VPS servers.


Ubuntu VPS vs Other Hosting Options for Node.js Apps

Choosing the right hosting environment is important because Node.js applications require stable performance, better scalability, server flexibility, and proper resource management for handling production traffic and long-running backend processes efficiently.

Hosting TypeBest ForLimitations
Shared HostingSmall static sitesLimited Node.js support
Ubuntu VPSMost Node.js projectsRequires server management
Cloud HostingLarge scalable systemsHigher complexity
Dedicated ServerEnterprise projectsHigher cost

For most developers, Ubuntu VPS provides the best balance between performance, scalability, server control, flexibility, and affordability, making it one of the most practical hosting solutions for modern Node.js applications.

Ubuntu VPS mainly offers:\n\n- Better cost efficiency

  • Strong application performance
  • Flexible server configuration
  • Easy scalability options
  • Full administrative control

This makes Ubuntu VPS suitable for APIs, SaaS platforms, backend applications, dashboards, automation tools, and production Node.js projects that require reliable hosting environments.


Why YouStable Ubuntu VPS Hosting Is Good for Node JS Projects

Modern Node.js applications require stable infrastructure, scalable server resources, reliable uptime, and flexible deployment environments to handle APIs, backend services, real-time systems, and production workloads without performance or stability issues.

YouStable Ubuntu VPS Hosting provides an environment suitable for:\n\n- Express.js apps

  • REST APIs
  • SaaS platforms
  • Backend applications
  • Real-time systems
  • Production Node.js hosting

Main Advantages

  • Ubuntu VPS deployment support
  • NVMe SSD storage
  • Full root access
  • Scalable resources
  • DDoS protection
  • Reliable uptime
  • Beginner-friendly VPS environment

These features make Ubuntu VPS hosting suitable for both beginners learning Node.js deployment and developers managing production applications that require better performance, server flexibility, and long-term scalability.

Also Read: Node.js Production Server Setup on Linux VPS


FAQs

Which Node.js version should you use for Ubuntu VPS deployment?

Using the latest Node.js LTS version is usually recommended because it provides better stability, long-term security updates, improved package compatibility, and reliable performance for production applications running on Ubuntu VPS servers.

Which ports are commonly used for Node.js applications?

Node.js applications usually run on custom ports internally, while Nginx handles public traffic through standard web ports on the Ubuntu VPS server.
Commonly used ports include:\n\n- Port 3000 for Node.js applications
Port 80 for HTTP traffic
Port 443 for HTTPS traffic
Port 22 for SSH access

Can Docker be used for Node.js deployment on Ubuntu VPS?

Yes, Docker can be used for Node.js deployment because it helps create isolated environments, simplifies application management, improves portability, and makes deployments more consistent across development and production servers.

What should you do before deploying a Node.js app to production?

Before production deployment, it is important to verify application stability, security settings, dependencies, environment variables, and server configurations to reduce deployment issues and improve long-term reliability.
Recommended pre-deployment checks include:\n\n- Test the application locally
Verify package dependencies
Configure environment variables
Enable HTTPS SSL certificates
Set up PM2 process management
Configure firewall protection
Backup important application data

How can you monitor a Node.js application on Ubuntu VPS?

Node.js applications can be monitored using PM2 logs, server monitoring tools, RAM usage tracking, CPU monitoring, and uptime checks to identify performance issues and maintain stable production environments.


Conclusion

Deploying a Node JS app on Ubuntu VPS becomes much easier once you understand the complete production workflow and properly configure the server environment for security, scalability, performance optimization, HTTPS support, and long-term application stability.

By combining Ubuntu VPS, Node.js, PM2, Nginx, SSL certificates, firewall protection, and modern deployment practices, developers can build reliable production environments capable of handling APIs, SaaS platforms, dashboards, backend services, and real-time applications efficiently.

For developers, startups, and growing Node.js projects, YouStable Ubuntu VPS Hosting provides scalable Ubuntu VPS infrastructure with full root access, NVMe SSD storage, reliable uptime, and flexible server resources suitable for modern production deployments in 2026.

Share via:

Sanjeet Chauhan

Sanjeet Chauhan is a blogger & SEO expert, dedicated to helping websites grow organically. He shares practical strategies, actionable tips, and insights to boost traffic, improve rankings, & maximize online presence.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top