Node.js app can't run on port 80 even though there's no other process blocking the port Node.js app can't run on port 80 even though there's no other process blocking the port linux linux

Node.js app can't run on port 80 even though there's no other process blocking the port


The error code EACCES means you don't have proper permissions to run applications on that port. On Linux systems, any port below 1024 requires root access.


Instead of running on port 80 you can redirect port 80 to your application's port (>1024) using

iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000

This will work if your application is running on port 3000.


Short answer: You can allow node access to that port using:

setcap 'cap_net_bind_service=+ep' /path/to/nodejs

long answer

Edit:

May not work on new node versions