Search code examples
node.jstaskportnode-modulesforever

Error : listen EACCES 0.0.0.0:80 foreverjs


I have a nodejs program running with forever https://www.npmjs.com/package/forever since several months (on Ubuntu 16.04.2 LTS). I had no problems (I have node v6.11.1).
But I recently wanted to use a package called bottleneck and for some reasons (because of the async syntax error) I wanted to update my nodejs.
So I followed his tip updating nodejs on ubuntu 16.04 (issues are coming up), I've executed :

sudo npm install -g n
sudo n lts

I've noticed that my app has stopped in forever list. So run :

forever start -o out.log -e err.log app.js

But my app was still stopped in forever list and no app.js task running (checked with htop). I check err.log and I find this error message :

Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1245:19)
at listen (net.js:1294:10)
at Server.listen (net.js:1390:5)
at Object.<anonymous> (/home/esu/pixelland006/app.js:35:6)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)

I tried different versions but nothing. It still doesn't work. So I run sudo n 6.11.1 to be back in v6.11.1 and I uninstalled n. I searched and I found that it may be a privilege problem. Now I'm using nmv instead of n and it still doesn't work, my app is still blocked in forever list.

But I've noticed something very weird, when I run :

forever start -o out.log -e err.log app.js

my app is blocked in forever list and no app.js task running (checked with htop), however when I do this :

sudo forever start -o out.log -e err.log app.js

forever tells me that my app is blocked in forever list but I see my app.js task running.

It worked since several months but since I tried to update nodejs, forever doesn't work anymore.

Now how can I run my app with forever ?
Thank you in advance


Solution

  • I guess I had broken packages. I reinstall everything: npm, nodejs... I upgraded my nodejs following this : https://askubuntu.com/a/548776 so I typed

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
    

    Now for some reasons I have to use forever with sudo so I type

    sudo forever list  
    

    to get the list and

    sudo forever start -o out.log -e err.log app.js  
    

    to start my app with forever. In both case don't forget to use sudo else it's confusing. Hope it will help someone someday.