skip to Main Content

Both of these each work to start my app:

node app
pm2 start app.js

The following does not work (app not working but PM2 status shows 2 instances online) and does not log any errors:

pm2 start app.js -i 2 --watch -l log/log.log

Launching with the following process.json file also does not work (but PM2 status still shows 2 instances online) and does not log any errors:

{
  "apps" : [{
    "name"        : "app",
    "script"      : "./app.js",
    "instances"   : 0,
    "exec_mode"   : "cluster",
    "watch"       : true,
    "ignore_watch"  : ["tmp","public","images_review"],
"error_file"      : "./logs/error.log",
"out_file"        : "./logs/out.log",
    "log_date_format"  : "YYYY-MM-DD HH:mm Z",
  }]
}

Launching in fork mode with the following process.json file still does not work but does log an error.

{
  "apps" : [{
    "name"        : "app",
    "script"      : "./app.js",
    "instances"   : 0,
    "watch"       : true,
    "ignore_watch"  : ["tmp","public","images_review"],
"error_file"      : "./logs/error.log",
"out_file"        : "./logs/out.log",
    "log_date_format"  : "YYYY-MM-DD HH:mm Z",
  }]
}

The error it logs is “Error: listen EADDRINUSE :::3000”. I checked and nothing is using port 3000. I also switched my node.js app to use a different port and it still gives an EADDRINUSE error for every port I try. I’m on a 2 core linode with Centos 7 running Plesk Onyx. What’s going on that I’m missing?

2

Answers


  1. Can you try running it with

    pm2 start app.js -i 0 -l log/log.log
    

    Which makes pm2 use the maximum number of cores available

    Then you can view your logs in real time using

    pm2 logs
    
    Login or Signup to reply.
  2. Got it solved with PM2 version somehow.

    Issue : With version 3.0.3, it did not work in cluster mode.
    However, when downgraded PM2 version to 3.0.0, it worked.

    Agree with @robertklep’s comment though.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search