1

What's I'm trying to do ?

Serve something on port 80 trough nodejs on WSL.

Commands run

  • npx serve -p 80
  • sudo npx serve -p 80

Error displayed

Error: listen EACCES: permission denied 0.0.0.0:80

Note: I'm sure port 80 is not busy !

For example, Docker container run well on port 80:

docker run -d -p 80:80 docker/getting-started

Other example

Here is some command that ✅ work and some that ❌doesn't work

  • ✅ docker run -d -p 80:80 docker/getting-started
  • ❌npx serve
  • ❌sudo npx serve
  • ✅ npx serve -p 4000
  • ❌npm run start (An express server)
  • ❌sudo npm run start (An express server)
  • ❌php -S localhost:80
  • ✅sudo php -S localhost:80

So it's seems that node don't take privilège of sudo. What's i'm missing, is there maybe something wrong on my node installation ?

EDIT: I find a solution here: https://stackoverflow.com/a/414258/2838586. But still doesn't know why it's doesn't work with sudo without this fix.

ZecKa
  • 2,552
  • 2
  • 21
  • 39

0 Answers0