garprogram
garprogram

Reputation: 31

How can I change the ip and port of pm2 web interface?

pm2 web interface - $pm2 web - listen on all the ip available on the machine and I would like it to only listen on localhost or ip of my choice.

$pm2 web
Launching web interface on 0.0.0.0:9615
[PM2][WARN] Applications pm2-http-interface not running, starting...
[PM2] App [pm2-http-interface] launched (1 instances)
[PM2] Process launched


pm2 version 2.1.6
node version 4.7.3

Thanks

EDITED:

I have researched about the environment variables and for the ip and port are:

"env_production" : {
   "NODE_ENV": "production",
   "PM2_API_IPADDR" : "IP here",
   "PM2_API_PORT" : "PORT here"
},

I have tried to start the web interface using the ecosystem.json file and I can not get it.

I am going to open another question on this subject.

How to start pm2 http web interface using the ecosystem.json file?

Upvotes: 3

Views: 8173

Answers (2)

asdf
asdf

Reputation: 357

To start the pm2 web interface with a different port and/or different listening address you can run it with the environment variable you found set.

eg. PM2_API_PORT=1234 PM2_API_IPADDR=192.168.1.1 pm2 web

Upvotes: 2

Kevin Hernandez
Kevin Hernandez

Reputation: 525

I recommend setting the environment variables in your ecosystem.json file.

So for example, I usually set NODE_ENV to be production / development or PORT to be 8080 and maybe, in your case, HOST to be localhost.

To access them in your node application, use process.env.<ENVIRONMENT VAR HERE>.

So for example in your javascript: var port_num = process.env.NODE_ENV;

Here's the pm2 documentation on how to set the environment variables, under the env property: http://pm2.keymetrics.io/docs/usage/deployment/

Upvotes: 1

Related Questions