Macos Big Sur port 80 permission denied with root

big surmacbook promacos

im facing this problem where im trying to start a server on port 80 of a Macbook Pro with MacOS Big Sur and im getting permission denied.

I tried running with sudo and also doing "sudo su" and then running the server.

I'm trying running a Nuxt (node js) server

$ sudo npm run dev
Error: listen EACCES: permission denied 127.0.0.1:80

Should i unlock something?

Best Answer

No, everything is working as intended. You need sudo to have a command line process listen on low ports. There’s nothing you want to unlock here as this is a protective feature.

I usually just test on ports higher than 1024 to avoid this risk entirely until it’s time to write a proper wrapper script, but all three options are just as suitable. (Use sudo, use setuid permissions, change the port listen number)

To use sudo - run a shell first, then the npm command

sudo -s
npm run dev
exit
Related Question