how to change default port on pm2 with nuxt 3 project

Hi I want to change the default port 3000 to 3001

according to nuxt doc we just need to add the port to .env file

I put those to my env but not working

#NITRO_PORT = "3001"
PORT = "3001"

how I build the nuxt 3

first I go to nuxt project directory run npm run build them pm2 start

after I check netstat -plant | grep 3001 does not return anything

but netstat -plant | grep 3000 did has return

0 :::3000
711987/PM2 v5.2.2:

btw this is my ecosystem.config.js

module.exports = {
    apps: [
            name: 'nuxt-php-framework',
            exec_mode: 'cluster',
            instances: 'max',
            script: './.output/server/index.mjs'

this is my package .json

  "name": "nuxt-php-framework",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  "dependencies": {
    "axios": "^1.2.1",
    "nuxt": "^3.0.0"
  "devDependencies": {
    "@nuxt/postcss8": "^1.1.3",
    "autoprefixer": "^10.4.13",
    "postcss": "^8.4.20",
    "tailwindcss": "^3.2.4"


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
January 4, 2023
Accepted Answer

Hi @stupidboy,

Add the port in the module.export section and then start your application. Something like the following should do the trick

  1. module.exports = {
  2. apps: [
  3. {
  4. name: 'nuxt-php-framework',
  5. port: 3001,
  6. exec_mode: 'cluster',
  7. instances: 'max',
  8. script: './.output/server/index.mjs'
  9. }
  10. ]
  11. }

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel