2

I used pm2 and forever modules to run my node js applications without end. Everything worked great, however as soon as I implemented HTTPS - port 443 - into my node app, I now have to run my in the following way - sudo node app.js

If I run it without sudo, so just node app.js alone, I get the following error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:904:11)

So I tried to implement forever into the sudo command, which would look like this:

sudo forever start app.js

However I get an error back:

sudo: forever: command not found

And when I try to run just:

forever start app.js

I get the same error as above (EACCES). I understand why this error appears, because its a port below 1000, but is there a way to run this node application on forever or something similar?

Any idea on how to solve this? Any help would be appreciated.

deeveeABC
  • 960
  • 3
  • 12
  • 34
  • Does it necessarily need to be run on port 443? All ports below 1000 are reserved for root, thats why you need sudo. If you change your port to something like 1234 it will work. – Matias Barrios Nov 07 '17 at 16:09
  • That being said, when you installed forever, you should have used the -g flag so it would install globally. – Matias Barrios Nov 07 '17 at 16:10
  • `EACCES` answered here: https://stackoverflow.com/questions/9164915/node-js-eacces-error-when-listening-on-most-ports and sudo command not found here: https://stackoverflow.com/questions/12996397/command-not-found-when-using-sudo – Fissure King Nov 07 '17 at 16:10
  • @MatiasBarrios yes it works on other ports. But this needs to be port 443 – deeveeABC Nov 07 '17 at 16:11
  • @deeveeABC Ok, then give full path to forever or install it globally as previously stated. You might find the information on the links Fissure King pasted. – Matias Barrios Nov 07 '17 at 16:13
  • I think you misunderstand the question. I know why it doesnt work, as I run on a low port. But is there a solution for this? – deeveeABC Nov 07 '17 at 16:16

0 Answers0