Pm2: Error binding to port 80

Created on 11 May 2014  路  2Comments  路  Source: Unitech/pm2

Hi,

I have a nodejs app (used only within the local home network) that I want to bind to port 80.

$ pm2 start app.js --name black
OR
$ sudo pm2 start app.js --name black

Results in:

$ less /home/[user]/.pm2/logs/black-err-3.log
Error: bind EACCES
at errnoException (net.js:901:11)
at net.js:1069:30
at Object.46:1 (cluster.js:592:5)
at handleResponse (cluster.js:171:41)
at respond (cluster.js:192:5)
at handleMessage (cluster.js:202:5)
at process.EventEmitter.emit (events.js:117:20)
at handleMessage (child_process.js:318:10)
at Pipe.channel.onread (child_process.js:345:11)

app.js is trying to bind to port 80, so I know it needs elevated creds. It's running as my user which is a root user. If I start the app like the below then it works:

$ sudo nodejs app.js

How do I make it so pm2 starts the app with elevated privs?

Thanks

Most helpful comment

I figured it out. The pm2 process needed to be started as root.

$ pm2 kill
$ sudo pm2 start app.js --name black

All 2 comments

I figured it out. The pm2 process needed to be started as root.

$ pm2 kill
$ sudo pm2 start app.js --name black

@chaos-git sudo pm2 does not work for me, I still get error Error: listen EACCES 0.0.0.0:80

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FujiHaruka picture FujiHaruka  路  3Comments

lefam picture lefam  路  3Comments

mario-mui picture mario-mui  路  3Comments

rangercyh picture rangercyh  路  4Comments

ghost picture ghost  路  3Comments