Deploying Node.js on an Ubuntu VPS gives developers control over the Node.js version, application process, Nginx configuration, HTTPS, firewall rules and server resources. This guide walks through a production-oriented setup using a supported Node.js LTS release, a non-root user, systemd or PM2, Nginx, Certbot and Ubuntu security controls.
To deploy a Node.js application on Ubuntu VPS, create a non-root administrative user, update Ubuntu, install a supported Node.js LTS version, deploy the application with npm, run it persistently using systemd or PM2, place Nginx in front of the Node.js process, allow only required firewall ports and enable HTTPS with a trusted TLS certificate. Keep the Node.js application bound to localhost when Nginx is handling public traffic.
A Node.js application often needs more control than basic shared hosting provides. With an Ubuntu VPS hosting environment, you can manage the operating system, Node.js runtime, packages, reverse proxy, firewall and application services according to your workload.
This makes an Ubuntu VPS useful for Node.js APIs, backend services, Express applications, real-time applications, SaaS platforms and development or staging environments. The resources required depend on application architecture, concurrent traffic, database activity, background tasks and other services running on the server.
| Component | Purpose | Recommended Approach |
|---|---|---|
| Ubuntu | Server operating system | Use a currently supported Ubuntu LTS release |
| Node.js | JavaScript runtime | Use a currently supported LTS release |
| npm | Dependency management | Use a lockfile and reproducible production installs |
| systemd or PM2 | Keeps the application running | Choose one process-management approach |
| Nginx | Public web server and reverse proxy | Proxy requests to Node.js on localhost |
| Certbot | TLS certificate automation | Configure HTTPS after DNS points to the VPS |
| UFW | Host firewall | Permit SSH, HTTP and HTTPS only as required |
You should have:
If you are still selecting infrastructure, compare VPS hosting, Linux VPS hosting and Ubuntu VPS hosting based on the CPU, memory, storage, network and management requirements of your Node.js application.
Connect over SSH using the IP address or hostname supplied for your VPS:
ssh root@YOUR_SERVER_IP
Refresh package metadata and install available package updates before configuring the application stack.
sudo apt update
sudo apt upgrade -y
If the update indicates that a reboot is required, plan an appropriate maintenance window and reboot before continuing.
Create a dedicated administrative account:
sudo adduser deploy
sudo usermod -aG sudo deploy
Configure your SSH public key for the deploy account and verify that you can log in successfully before changing any SSH authentication settings.
ssh deploy@YOUR_SERVER_IP
Running application processes as an unprivileged user limits the privileges available to the application if the process is compromised.
At the time this article was technically verified, Node.js 26.x is an LTS release. Because Node.js versions change over time, check the official Node.js release page before deploying a new production server.
Node.js lists version-manager installation methods such as NVM among its recommended installation approaches. For the version current at this article's verification date:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bash
. "$HOME/.nvm/nvm.sh"
nvm install 26
nvm alias default 26
node -v
npm -v
Create an application directory:
mkdir -p ~/apps/nodeapp
cd ~/apps/nodeapp
If you already have an application, clone or securely transfer it into this directory. For a minimal demonstration:
npm init -y
npm install express
Create app.js:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
const HOST = '127.0.0.1';
app.get('/', (req, res) => {
res.send('Node.js application is running on Ubuntu VPS.');
});
app.get('/health', (req, res) => {
res.status(200).json({ status: 'ok' });
});
const server = app.listen(PORT, HOST, () => {
console.log(`Node.js listening on http://${HOST}:${PORT}`);
});
function shutdown(signal) {
console.log(`${signal} received. Closing HTTP server...`);
server.close(() => {
process.exit(0);
});
}
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
Test the application:
node app.js
In another SSH session:
curl http://127.0.0.1:3000/health
You should receive a response similar to:
{"status":"ok"}
Stop the foreground process with Ctrl+C.
Avoid placing database passwords, API keys and other secrets directly in source code or committing them to Git.
Create an environment file:
nano ~/apps/nodeapp/.env
Example:
NODE_ENV=production
PORT=3000
Restrict access to the file:
chmod 600 ~/apps/nodeapp/.env
Production secrets should be managed according to your organization's secrets-management and access-control policies.
Do not rely on an interactive node app.js shell session for a production service. Use a service/process manager so the application can be monitored and restarted according to a defined policy.
| Option | Best For | Key Advantage |
|---|---|---|
| systemd | Administrators wanting native Ubuntu service management | Integrated service lifecycle, logging and boot management |
| PM2 | Node.js teams wanting Node-focused process management | Convenient app management, logs and startup integration |
First determine the exact Node.js binary path:
which node
It may look similar to:
/home/deploy/.nvm/versions/node/v26.x.x/bin/node
Use the actual path returned by your server when creating the service.
sudo nano /etc/systemd/system/nodeapp.service
Example unit:
[Unit]
Description=Net2Secure Node.js Application
After=network.target
[Service]
Type=simple
User=deploy
Group=deploy
WorkingDirectory=/home/deploy/apps/nodeapp
EnvironmentFile=-/home/deploy/apps/nodeapp/.env
ExecStart=/home/deploy/.nvm/versions/node/v26.x.x/bin/node /home/deploy/apps/nodeapp/app.js
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
v26.x.x with the exact version directory returned by which node. If NVM later installs a different Node.js version, update the systemd service's ExecStart path before removing the old runtime.Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl enable --now nodeapp
sudo systemctl status nodeapp --no-pager
View application logs:
sudo journalctl -u nodeapp -f
If you prefer PM2, do not simultaneously run the same application on the same port with systemd.
npm install -g pm2
cd ~/apps/nodeapp
pm2 start app.js --name nodeapp
pm2 status
pm2 logs nodeapp
Save the current process list:
pm2 save
Generate the startup configuration:
pm2 startup
PM2 will print a command containing the appropriate user, home directory and Node.js path. Run the exact command PM2 generates, then run:
pm2 save
Rather than exposing the Node.js application directly to the Internet, Nginx can accept public HTTP/HTTPS traffic and proxy requests to the application listening on 127.0.0.1:3000.
sudo apt update
sudo apt install nginx -y
sudo systemctl status nginx --no-pager
sudo nano /etc/nginx/sites-available/nodeapp
Replace example.com with your actual domain:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
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;
}
}
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/nodeapp /etc/nginx/sites-enabled/nodeapp
sudo nginx -t
sudo systemctl reload nginx
If this is the only site on the server and the default Nginx site is no longer required, you can disable the default server block:
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx
Applications using WebSocket connections require additional Nginx proxy configuration. Add the appropriate Upgrade and Connection handling only when your application requires WebSockets rather than copying it into every deployment unnecessarily.
Ubuntu documents UFW as its default firewall configuration tool. Before enabling it, make sure SSH access is explicitly allowed so you do not lock yourself out.
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status verbose
Because Node.js is listening only on 127.0.0.1:3000, port 3000 does not need to be opened publicly for this deployment architecture.
Before requesting a certificate, confirm that your domain's DNS records resolve to this VPS and that HTTP traffic can reach Nginx.
Certbot currently recommends Snap for most Linux installations. If you do not already have another Certbot installation:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot
If the symbolic link already exists, do not create a duplicate.
Request and configure HTTPS through Nginx:
sudo certbot --nginx
Then test certificate renewal:
sudo certbot renew --dry-run
Certbot's supported installation methods configure automated renewal mechanisms, but a dry-run is useful for confirming that your server can renew certificates successfully.
Deploying the application is only the beginning. Production Node.js hosting also requires ongoing maintenance.
sudo apt update
sudo apt upgrade
Check the automatic update service:
sudo systemctl status unattended-upgrades --no-pager
Ubuntu Server includes support for automatic security updates, but you should still maintain an operational update and reboot policy appropriate for your application.
node -v
nvm ls
nvm ls-remote --lts
Test application compatibility before moving a production workload to a new Node.js major version.
For an application repository containing a valid package-lock.json, a production deployment can use:
npm ci --omit=dev
Keep the lockfile under version control and review dependency changes during deployment.
The Node.js process normally does not need root privileges when Nginx is serving public ports 80 and 443. Run the application as its deployment or service user instead.
With the reverse-proxy architecture used in this guide, Nginx is public while Node.js listens only on localhost. This reduces unnecessary direct exposure of the application service.
Compare Net2Secure Ubuntu and Linux VPS options for APIs, application servers, development environments and other Node.js workloads. Select resources according to your application's measured CPU, memory, storage and network requirements.
For an existing Git-based application, a typical deployment workflow may look like the following. Adapt the branch, build command and application lifecycle to your project.
cd ~/apps
git clone YOUR_REPOSITORY_URL nodeapp
cd nodeapp
npm ci --omit=dev
# If your project requires a production build:
# npm run build
# systemd deployment:
sudo systemctl restart nodeapp
# OR, if PM2 is your chosen process manager:
# pm2 restart nodeapp --update-env
There is no universal VPS size that guarantees a particular Node.js performance level. Measure the application under a representative workload before increasing server resources.
| Area | What to Monitor | Possible Action |
|---|---|---|
| CPU | Sustained CPU utilization and event-loop-heavy tasks | Optimize code, offload jobs or scale processing capacity |
| Memory | Node.js heap usage, system RAM and swap activity | Investigate leaks or increase memory when justified |
| Storage | Disk latency, database I/O and log growth | Optimize storage access and log retention |
| Network | Latency, throughput and connection volume | Review server location, proxy settings and architecture |
| Application | Response times, error rate and request throughput | Profile bottlenecks before adding resources |
Network distance and routing can affect latency. If your Node.js application primarily serves visitors in India, evaluate a Node.js hosting India deployment by measuring real network latency and application response times from your target audience. Geographic proximity alone does not guarantee application performance; network routing and application design also matter.
Nginx can handle the Internet-facing HTTP/HTTPS connection while Node.js serves application requests behind it. This also gives you a central place to manage TLS, proxy headers and HTTP-layer configuration.
Before increasing VPS CPU or RAM, determine whether the bottleneck is CPU, application code, database queries, external APIs, memory pressure, storage I/O or network latency. Scaling infrastructure cannot compensate for every application bottleneck.
| Problem | Diagnostic Command | What to Check |
|---|---|---|
| Application will not start | sudo journalctl -u nodeapp -n 100 |
Node path, permissions, environment variables and stack trace |
| PM2 app is offline | pm2 logs nodeapp |
Runtime errors, missing environment variables and dependencies |
| Nginx returns 502 | curl http://127.0.0.1:3000 |
Confirm Node.js is listening on the expected local port |
| Nginx configuration fails | sudo nginx -t |
Syntax errors and duplicate server blocks |
| Cannot reach website | sudo ufw status |
Ports 80/443, DNS and upstream network firewall |
| Unsure which process owns port 3000 | sudo ss -ltnp | grep :3000 |
Duplicate process or unexpected service |
| Nginx proxy error | sudo tail -f /var/log/nginx/error.log |
Connection refused, timeout or permissions |
| Certificate renewal concern | sudo certbot renew --dry-run |
DNS, ports, certificate configuration and renewal process |
If you want to evaluate a VPS environment for a Node.js project, review Net2Secure's current trial pages and confirm the available operating system, resources, eligibility and activation conditions before testing.
Yes. A supported Ubuntu VPS can provide a configurable Linux environment for Node.js applications, including control over the runtime version, npm packages, Nginx, process management, firewall and TLS configuration. The correct VPS resources depend on the specific application and traffic profile.
Install a supported Node.js LTS release, transfer your application, install dependencies, run the application under a non-root account, manage the process with systemd or PM2, configure Nginx as a reverse proxy, enable the firewall and add HTTPS for public production use.
Both can manage a Node.js application. systemd is Ubuntu's native service manager and integrates directly with the operating system. PM2 provides Node.js-focused process-management features. Choose one primary process supervisor for each application rather than running competing supervisors for the same process.
Node.js can serve HTTP directly, but Nginx is commonly used as an Internet-facing reverse proxy for production deployments. It can proxy requests to Node.js on localhost and provide a central layer for TLS and HTTP configuration.
Use a currently supported Node.js LTS release that your application supports. At this article's November 2026 technical verification, Node.js 26.x is an LTS line. Re-check the official Node.js release schedule when deploying or upgrading because support status changes.
For production hosting, a supported Ubuntu LTS release is generally a practical choice because of its longer maintenance lifecycle. Ubuntu 26.04 LTS and Ubuntu 24.04 LTS are supported at the time this guide was reviewed. Verify the Ubuntu lifecycle before a new deployment.
Normally, no. Run the application under an unprivileged account and let Nginx handle public HTTP and HTTPS connections. Administrative privileges should be used only when required for server management.
Not for the reverse-proxy configuration in this guide. Node.js listens on 127.0.0.1:3000, while Nginx handles public traffic on ports 80 and 443. Open the Node.js application port publicly only when your architecture specifically requires it.
Point the domain to the VPS, configure Nginx for the domain and obtain a trusted TLS certificate. Certbot can integrate with Nginx to obtain and configure a Let's Encrypt certificate. Test renewal after setup.
A 502 error frequently means Nginx cannot successfully communicate with its configured upstream application. Check that the Node.js process is running, confirm the host and port, inspect application logs and test curl http://127.0.0.1:3000 directly from the VPS.
There is no reliable universal RAM requirement. Memory needs depend on the framework, application code, traffic, Node.js heap usage, databases, caches and additional services. Start from measured workload requirements and monitor memory usage before scaling.
Yes, provided the VPS has sufficient resources. Run each application on its own local port and create separate Nginx server blocks or routing rules. Keep service configurations, environment variables, permissions and logs clearly separated.
Yes. Businesses and developers serving Indian users can evaluate Ubuntu VPS infrastructure in India for Node.js applications. Measure network latency and application performance from your actual user locations rather than assuming geography alone guarantees faster performance.
Net2Secure publishes VPS trial and Linux VPS trial information. Review the current trial pages and confirm eligibility, operating system availability, resources and testing conditions before deployment.
A secure Node.js VPS deployment is more than installing Node and running npm start. Use a supported Ubuntu and Node.js release, run application processes without root privileges, keep Node.js behind Nginx, expose only required network services, use HTTPS, maintain security updates and monitor application health.
For developers comparing hosting environments, Net2Secure provides information about Ubuntu VPS hosting , Linux VPS hosting and VPS hosting . Choose infrastructure based on the measurable requirements of your application rather than relying on a generic VPS size recommendation.
Compare a suitable VPS environment, deploy your Node.js stack and validate your application under realistic workload conditions before moving production traffic.
Editorial note: Technical instructions were verified against official documentation on November 17, 2026. Software versions, support lifecycles and installation methods should be revalidated when this guide is updated.