How to deploy Nuxt app in Ubuntu Server

How to deploy Nuxt app in Ubuntu Server

Deploy Nuxt App in Linux VM

2 May 2026

Deploy Nuxt App in Ubuntu Server

For this, first you need to have a running Ubuntu server and a Nuxt app to build.

Build the Nuxt App

Navigate to your project directory and build the app using the following command
bash
npm run build
bash
  Building Nuxt for production...

  Nuxt 4.4.2 (with Nitro 2.13.3, Vite 7.3.1 and Vue 3.5.32)
 Processed 2 collections and 0 files in 69.58ms (0 cached, 0 parsed)                                                                                              @nuxt/content 2:46:56 PM
 Nuxt Icon server bundle mode is set to local                                                                                                                                   2:46:57 PM

  Nitro preset: node-server
 Building client...  
The build folder will be .output. If you look into the folder, you can see a lot of build files. Inside the server folder, you can see the node_modules as well. This is when you build the app. Nuxt bundles everything your application needs into a standalone package, so you don't have to run npm install it on your server.
Transferring those files to the remote server will take much time, so we need zip them. Use the following command to zip the folder
bash
tar -czf build.tar.gz .output
Now, transfer the file to our Ubuntu server.
bash
scp build.tar.gz user@your-server-ip:~
Now SSH into the remote Ubuntu server
bash
ssh user@your-server-ip
Provide the password if required. Here, user is your Ubuntu server username that might be root or ubuntu
Inside the Ubuntu server, untar the file
bash
tar -xzf build.tar.gz

Install NodeJS on the Server

We need to install the node inside the server. We are using nvm node manager to do so, it's due to get rid of version conflict between the node used to develop locally and the server. First, install the nvm
bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
Now install NodeJS
bash
nvm install v22.17.1
Make sure to use your own node version.
Verify the node is installed
bash
node -v

Install and Set Up Process Manager(PM2)

Install PM2

We are going to manage the process using pm2, which helps to run the application in the background.
bash
npm install -g pm2
Let's create a configuration file for pm2 to manage. Create the file in the same directory where our .output folder is located.
bash
touch ecosystem.config.cjs
Set up the config file
javascript
module.exports = {
  apps: [
    {
      name: 'csbyte',
      port: '3000',
      exec_mode: 'cluster',
      instances: 'max',
      script: './.output/server/index.mjs'
    }
  ]
}
Here, use your own name. You can see the instances are set to max, which will create multiple instances as the user requests increase. When you use Cluster Mode, PM2 acts as a load balancer. Instead of running one single process, it will utilize all available CPU cores on your Ubuntu server.
If your server have 2 core cpu, setting instances max will create one instance per core, resulting in 2 instances.

Start pm2

Simply, start the pm2 using the following command
bash
pm2 start ecosystem.config.cjs
Article Image
The output looks something like the above, for instance, set to 1.
Now you can open the IP address with port 3000 it will load the app.
http://your-server-ip-address:3000/

Run Node APP in the background

Run the following command to run your node app in the background
bash
pm2 save
pm2 startup

Useful command for PM2

bash
pm2 delete app-name
This will delete the app use app-name as your configured name in ecosystem.config.cjs
bash
pm2 logs
This will list the logs of all the running processes if you have multiple nuxt app setup.
bash
pm2 logs app-name
This will log for a specific Nuxt app.
bash
pm2 logs app-name --lines 100
This will show the older logs, the last 100 lines
bash
pm2 monit
This will show a more visual way to monitor logs alongside CPU and RAM usage
If your logs are getting too cluttered and you want to wipe them to start fresh
bash
pm2 flush
All these logs are located inside these locations.
Output console logs:
bash
~/.pm2/logs/app-name-out.log
Errors logs:
bash
~/.pm2/logs/app-name-error.log
This is the process to deploy our Nuxt application.