user12397996
user12397996

Reputation:

Changing PORT of a porcess in pm2

I have a process running in PORT 3000 and I want to deploy this process in any other PORT. How can I do this?

Upvotes: 1

Views: 6210

Answers (2)

otw
otw

Reputation: 660

PM2 does not decide your port, it's however the app PM2 is managing binds to the port is what you need to change.

Upvotes: 1

Ivan V.
Ivan V.

Reputation: 8081

This is a simple configuration for pm2:

module.exports = {
  apps : [
      {
        name: "myapp",
        script: "./app.js",
        watch: true,
        instance_var: 'INSTANCE_ID',
        env: {
            "PORT": 3000,
            "NODE_ENV": "development"
        }
      }
  ]
}

There is an apps.env.PORT key you can use.

Upvotes: 3

Related Questions