Deploy Nuxt on Hostinger VPS: PM2, Nginx, Namecheap DNS & CDN

by Fahim Mahmud Chisti

To deploy a Nuxt 3 or Nuxt 4 app with server-side rendering (SSR) on a Hostinger VPS, build it into Nitro’s .output folder and run that server under PM2. Nginx goes in front for HTTPS and static files. This guide goes from a fresh Ubuntu server to a live HTTPS site with Namecheap DNS and a CDN. Nuxt 3 itself reached end-of-life on 31 July 2026; the same steps apply unchanged to Nuxt 4, which builds to the same Nitro .output folder.

Quick answer: Run npm run build, start .output/server/index.mjs with PM2 on 127.0.0.1:3000, and let Nginx serve /_nuxt/ from disk while it proxies everything else to Nitro. Point the domain at the VPS in Namecheap and add HTTPS with Certbot.

  1. Install Node.js 24 LTS and create a non-root deploy user.
  2. Clone the app into /var/www/my-nuxt-app, then run npm install and npm run build.
  3. Start it from a PM2 ecosystem file, then run pm2 save and pm2 startup.
  4. Add the A record in Namecheap and create the Nginx server block; run sudo nginx -t before reloading.
  5. Run sudo certbot --nginx, then put the CDN in front with HTTPS to the origin.
In this guide
  1. Before You Start
  2. 1. Server Baseline and Node.js Environment Setup
  3. 2. Clone, Build, and Configure the Nuxt App
  4. 3. Process Management with PM2
  5. 4. Point Namecheap DNS to Hostinger VPS
  6. 5. Nginx Reverse Proxy and Static Asset Tuning
  7. 6. Secure with Free Let’s Encrypt SSL
  8. 7. Layer an Edge CDN for Asset Offloading
  9. 8. Zero-Downtime Deployment Script
  10. Common Problems and Fixes
  11. Frequently Asked Questions
  12. Next Steps
Nuxt 3 SSR app running on PM2 and Nginx on a Hostinger VPS

Before You Start

  • Server: a Hostinger VPS running Ubuntu 22.04 or 24.04, its public IP, and root SSH access.
  • Domain: a domain at Namecheap using Namecheap BasicDNS.
  • App: a Nuxt app that uses SSR (not a static nuxt generate build) in a Git repository.
  • Memory: on a 1–2 GB plan, create the swap file from the Common Problems section before you build.
  • Firewall: Step 1 installs ufw but does not switch it on. If you enable it, run sudo ufw allow OpenSSH and sudo ufw allow 'Nginx Full' first, or you lock yourself out and Certbot cannot reach port 80.
  • Time and risk: about 45–60 minutes. If the domain already serves a live site elsewhere, test Steps 1–3 before you change its DNS in Step 4.

1. Server Baseline and Node.js Environment Setup

Spin up a fresh Ubuntu 22.04 or 24.04 LTS instance in your Hostinger dashboard. SSH in as root and update the base packages before touching your application code.

First, update the package index and install basic tools (curl, git, the ufw firewall and fail2ban, which blocks repeated failed SSH logins):

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git ufw fail2ban

Nuxt 3 and its underlying Nitro engine run best on an Active LTS version of Node. We’ll pull Node.js 24 LTS directly from the official NodeSource repository (Node.js 20 is end-of-life). Read the downloaded setup script before running it as root.

Add the repository and install Node along with npm:

curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
node -v
npm -v

node -v should print v24.x.x. Running your app as root would give any bug in it full control of the server, so create a dedicated deploy user with sudo access and switch to it:

adduser deploy
usermod -aG sudo deploy
su - deploy

2. Clone, Build, and Configure the Nuxt App

Now, as the deploy user, create the app folder and get your code onto the server. If you’ve already read our guide on how to deploy Next.js on Hostinger VPS, the layout will feel familiar, though Nuxt compiles its output differently through Nitro.

Create a directory under /var/www/ and hand ownership over to your deploy user:

sudo mkdir -p /var/www/my-nuxt-app
sudo chown -R deploy:deploy /var/www/my-nuxt-app
cd /var/www/my-nuxt-app

Clone your repository into this folder (for example git clone https://github.com/your-username/your-repo.git ., with the trailing dot) or upload your files here. Once they’re in place, install your dependencies:

npm install

Create a .env file for the values the build needs:

API_BASE_URL=https://api.example.com

Nuxt reads this file during npm run build, but the built production server does not load .env files. Anything needed at runtime (port, bind address, NUXT_-prefixed runtime config) has to be in the process environment, which is what the env block of the PM2 file in the next step is for.

Nuxt uses Nitro as its server engine. The build command produces a self-contained production bundle in the .output folder, so the running server does not need the project’s node_modules directory.

Run the production build on the server. If it stops with Killed or a heap error, add swap (see Common Problems) and run it again:

npm run build

Once the build finishes, ls .output/server/index.mjs should list the file. That single entry file runs your entire SSR application.

3. Process Management with PM2

If your VPS reboots or your app hits an unhandled error, the site should come back on its own. PM2 starts the app in the background, restarts it after crashes and reboots, and keeps its logs.

Install PM2 globally:

sudo npm install -g pm2

Instead of passing messy inline CLI flags every time, create an ecosystem configuration file at /var/www/my-nuxt-app/ecosystem.config.cjs:

module.exports = {
  apps: [
    {
      name: 'nuxt-production',
      port: '3000',
      exec_mode: 'cluster',
      instances: 'max',
      script: './.output/server/index.mjs',
      env: {
        NODE_ENV: 'production',
        PORT: 3000,
        NITRO_PORT: 3000,
        NITRO_HOST: '127.0.0.1'
      }
    }
  ]
};

Pay attention to exec_mode: 'cluster'. Because Nitro’s server bundle keeps no state between requests, PM2 can run one worker per CPU core and share traffic between them without any changes to your code.

Start the app and configure PM2 to boot on system startup:

pm2 start ecosystem.config.cjs
pm2 save
pm2 startup

Copy and run the sudo env PATH=... command that PM2 spits out in your terminal. Then verify the server is responding locally:

curl -I http://127.0.0.1:3000

You should see an HTTP/1.1 200 OK response directly from Nitro, and pm2 status should list nuxt-production as online. If it shows errored, read the reason with pm2 logs nuxt-production.

4. Point Namecheap DNS to Hostinger VPS

Before issuing SSL certificates, your domain needs to point directly to your Hostinger VPS public IP. Log in to your Namecheap account.

Here is the setup in Namecheap Advanced DNS:

  1. Go to your Domain List and click Manage next to your domain.
  2. Open the Advanced DNS tab.
  3. Make sure Nameservers is set to Namecheap BasicDNS.
  4. Under Host Records, add or update these two records:
  • A Record: Host @ | Value YOUR_VPS_PUBLIC_IP | TTL Automatic (or 1 min during migration)
  • CNAME Record: Host www | Value example.com. | TTL Automatic

Delete any other A, CNAME or URL Redirect records for @ and www that point elsewhere, so the domain has only one answer. Leave MX and TXT records alone so email keeps working.

Give it a few minutes, then verify DNS propagation from your local machine:

dig +short example.com A

Once it resolves to your VPS IP, you’re ready to wire up Nginx.

5. Nginx Reverse Proxy and Static Asset Tuning

Nginx sits in front of the app. It listens on ports 80 and 443, handles HTTPS, serves static assets (JS chunks, CSS, images) straight from disk without touching Node, and passes SSR page requests to the app on port 3000.

Install Nginx:

sudo apt install -y nginx

Create a server block configuration at /etc/nginx/sites-available/example.com:

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    # Static assets built by Nuxt/Nitro
    location /_nuxt/ {
        alias /var/www/my-nuxt-app/.output/public/_nuxt/;
        access_log off;
        add_header Cache-Control "public, max-age=31536000, immutable";
    }
    # Public folder files (robots.txt, favicon.ico, images)
    location / {
        root /var/www/my-nuxt-app/.output/public;
        try_files $uri @nitro;
    }
    # Dynamic SSR proxy
    location @nitro {
        proxy_pass http://127.0.0.1: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_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 60s;
        proxy_connect_timeout 60s;
    }
}

try_files deliberately omits $uri/: with it, a request for / matches the public directory and Nginx answers 403 instead of proxying to Nitro.

The biggest performance win here is the /_nuxt/ block. Nginx serves those hashed bundles directly from disk with immutable 1-year cache headers, freeing up Node to focus entirely on SSR execution.

Enable the site and test your configuration syntax. The commands also remove the default welcome site; skip that line if another site on this server still uses it. Reload only after nginx -t prints syntax is ok and test is successful:

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

Then run curl -I http://example.com from your own computer. A 200 OK means DNS, Nginx and Nitro are connected; a 502 means Nginx cannot reach the app (see Common Problems).

6. Secure with Free Let’s Encrypt SSL

Now lock down your domain with a free TLS certificate from Let’s Encrypt using Certbot.

Install Certbot and run the Nginx plugin:

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

Certbot will ask for an email address and automatically update your Nginx config with HTTPS redirection blocks. Test that renewal works; a passing run reports that the simulated renewal succeeded:

sudo certbot renew --dry-run

Open https://example.com in a browser to confirm the padlock and your app.

7. Layer an Edge CDN for Asset Offloading

While Nginx is fast, putting an edge CDN in front of your server lets static bundles and cached HTML be served from a location close to each visitor while protecting your origin server from traffic spikes.

Here are the key CDN settings to apply:

  • Origin Server: Point your CDN origin to your VPS IP or origin hostname.
  • Origin Protocol: Set to HTTPS Only (Port 443) to prevent redirect loops. If you get stuck in a loop, read our fix for SSL ERR_TOO_MANY_REDIRECTS on Nginx behind a CDN.
  • Cache Rule for /_nuxt/*: Set Edge Cache TTL to 1 Year (31536000s). These files include unique content hashes on every build and are completely immutable.
  • Dynamic SSR Routes: Set default Edge Cache TTL to Bypass or a short micro-cache (10–30s) depending on how dynamic your content is.

For heavier traffic, you can also turn on your CDN’s origin shield or tiered caching so a fresh deployment doesn’t send every edge location to your server at once; see how to prevent CDN cache stampedes with origin shield and request collapsing.

8. Zero-Downtime Deployment Script

You don’t want to SSH in and run five manual build commands every time you push a hotfix. As the deploy user, create a deploy script at /var/www/my-nuxt-app/deploy.sh:

#!/bin/bash
set -e
cd /var/www/my-nuxt-app
echo "Fetching latest code from Git..."
git pull origin main
echo "Installing dependencies..."
npm ci --prefer-offline
echo "Building Nuxt project..."
npm run build
echo "Reloading PM2 cluster..."
pm2 reload ecosystem.config.cjs --update-env
echo "Deployment complete!"

Make it executable:

chmod +x /var/www/my-nuxt-app/deploy.sh

Run it with ./deploy.sh from the app folder; it stops at the first failing command because of set -e. The key line is pm2 reload. Unlike a standard restart, it replaces workers one at a time, starting new ones with the updated build before stopping the old ones, so users don’t see a 502 Bad Gateway. One caveat: npm run build rewrites .output while the old workers still serve from it, so for strict zero downtime build in a separate release directory (or in CI) and switch a symlink before the reload.

Common Problems and Fixes

These are the problems that most often show up with this setup, especially on entry-level VPS plans.

1. 502 Bad Gateway or a 403 on the Homepage

A 502 means Nginx cannot reach the app on port 3000: run pm2 status and curl -I http://127.0.0.1:3000 on the server, and check pm2 logs nuxt-production if the app is not online. A 403 on / usually means $uri/ was added back to the try_files line in the server block.

2. Out of Memory (OOM) During Build

On 1 GB or 2 GB RAM plans, npm run build can get killed by the kernel or crash with a JavaScript heap out of memory error while the bundler compiles chunks.

The fastest fix is adding a 2 GB swap file:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

If you still get the heap error, raise Node’s own limit: NODE_OPTIONS=--max-old-space-size=2048 npm run build.

3. Missing Client IP in SSR Logs

Behind Nginx, useRequestEvent()?.node.req.socket.remoteAddress will just log 127.0.0.1. Nginx already passes the visitor’s address in X-Forwarded-For (see the config above), so read it on the server with getRequestIP and its xForwardedFor option, for example in a small server middleware:

// server/middleware/client-ip.ts
export default defineEventHandler((event) => {
  const ip = getRequestIP(event, { xForwardedFor: true })
  console.log(`${ip} ${event.method} ${event.path}`)
})

The header starts with whatever the client or CDN sent, so it is fine for logs but not for access decisions.

For deeper runtime settings, check the official Nuxt Deployment documentation and the Nitro Engine guides.

Frequently Asked Questions

Can I run Nuxt 3 on Hostinger Shared Web Hosting instead of a VPS?

On the plans that include Node.js web apps (Business Web Hosting and the Cloud plans), yes: hPanel builds and runs a Nuxt SSR app for you, without the PM2 and Nginx control described here. On other shared plans you are limited to a static build from npx nuxt generate.

Why should I use PM2 instead of systemd?

systemd is great, but PM2 gives you out-of-the-box cluster mode, simple log tailing via pm2 logs, live resource monitoring with pm2 monit, and zero-downtime rolling reloads without building complex service templates.

What is the difference between pm2 restart and pm2 reload?

pm2 restart kills all running worker processes at once and reboots them, resulting in a couple of seconds of downtime. pm2 reload rotates through the cluster sequentially, keeping at least one worker active to handle requests during code refreshes.

Do I need to run npm install on the server for every deploy?

Use npm ci instead—it strictly respects your package-lock.json and installs faster. If you want even faster deploys, build your .output artifacts inside a GitHub Actions CI pipeline and rsync only the build output to your VPS.

Next Steps

With the app live over HTTPS, keep it healthy over time. PM2’s log files grow without limit unless you rotate them, and the boot service should survive Node upgrades. Our guide to configuring PM2 startup scripts and log rotation on a VPS covers both. After that, consider moving the build into CI so the server only receives the finished .output folder.

all_in_one_marketing_tool