0

I have my nodejs running on port 9090 and I somehow made it work on port 80 by using the following setup

sudo apt-get install libcap2-bin sudo setcap cap_net_bind_service=+ep

and when I run as nodejs server.js 80, I'm able to run my client as localhost without any port specified.

But when I run the same with nodemon server.js 80, it throws an error

Error: listen EACCES 0.0.0.0:80

How can I run it with nodemon and port 80

Thanks in advance.

kumar
  • 21
  • 1
  • 2

2 Answers2

0

You most likely need elevated privileges to bind to a port below 1024. try sudo nodemon server.js 80.

Sello Mkantjwa
  • 1,798
  • 1
  • 20
  • 36
0

You need root permissions to run on 'privileged' ports, so run it as sudo. I advise you to use a proxy like nginx for proxying your requests to ports such as 80, or atleast re-routing your traffic via iptables (how-to here).

Milan Velebit
  • 1,933
  • 2
  • 15
  • 32