Search code examples
node.jsexpresssocket.iopermissions

Error: listen EACCES: permission denied 0.0.0.0:443


When running npm start showing this permission issue.

 Error: listen EACCES: permission denied 0.0.0.0:443
    at Server.setupListenHandle [as _listen2] (node:net:1302:21)
    at listenInCluster (node:net:1367:12)
    at Server.listen (node:net:1454:7)

Solution

  • Running server with npm on https port 443 was fine with sudo. Until I had to upgrade npm (from v6 to v8). And googling initially didn't help, because everyone is suggesting sudo.

    Found duplicate answer here. Referring to another site.

    A lot of people get stuck here, but the solution is easy. There a few options but this is the one I like. Type the following commands:

    sudo apt-get install libcap2-bin 
    sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\`` 
    

    Now, when you tell a Node application that you want it to run on port 80, it will not complain.