Pm2: Starting pm2 with elevated privileges

Created on 13 May 2014  路  3Comments  路  Source: Unitech/pm2

Related to: https://github.com/Unitech/pm2/issues/456

How do I get pm2 to load on startup with elevated privileges? I'm trying to have it bind an app to port 80 but it fails unless I do pm2 kill && sudo pm2 start app.js.

Thanks

Most helpful comment

I don't mind pm2 running as root, but even though I have it starting up in init.d (as root), pm2 ends up running without priviledges. For this reason it won't bind to port 80. The solution is that every time I boot the OS I need to run "pm2 kill; sudo pm2 start app.js".

I hope that makes sense.

All 3 comments

sudo pm2 start server.js

is indeed the solution to start on a port < 1000. Only root can bind to those ports so it's making sense to me.
Don't see the issue there.

If you really don't like pm2 executed as root, you can look for workarounds here:

http://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-1024-on-l

I don't mind pm2 running as root, but even though I have it starting up in init.d (as root), pm2 ends up running without priviledges. For this reason it won't bind to port 80. The solution is that every time I boot the OS I need to run "pm2 kill; sudo pm2 start app.js".

I hope that makes sense.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

getvega picture getvega  路  3Comments

alexpts picture alexpts  路  3Comments

bragma picture bragma  路  4Comments

mario-mui picture mario-mui  路  3Comments

phra picture phra  路  3Comments