Home > Software design >  Express JS code doesnt work with pm2, but when started manually ("node ."/"node index
Express JS code doesnt work with pm2, but when started manually ("node ."/"node index

Time:12-23

I got a Discord JS project running which works fine, now I wanted to also run a simple express script to receive a post request. When I do "node ." the code works and successfully logs the requests, if I do "pm2 start index.js --name xyz" the code also starts, logs its boot up message, doesn't shut down, but also doesn't react to any requests. There is simply no response at the set port by express.

Running on an Ubuntu VPS.

CodePudding user response:

Works if I do "pm2 start index.js --name xyz -- --port XXXX" I don't know why and would like to know how these extra arguments work if anyone could explain.

CodePudding user response:

You can read about arguments on the official docs

It's likely you have a runtime error. Please read your own logger files and ~/.pm2/logs/*.log and see if you can find anything. Had it been a syntax error, it would have shut down immediately. Yet, always pm2 statusafter start to double check it.

  • Related