'getting error while running production env in node js

 Error: listen EACCES: permission denied 8000,
    at Server.setupListenHandle [as _listen2] (node:net:1313:21)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1476:5)

Trying to run in production and getting this error. Tried finding a solution:

  • killing all nodes or
  • deleteting node modules and re-installing

If anyone has any answer, please shed the light.



Solution 1:[1]

I assume you're listening on the port 80.

The TCP/IP port numbers below 1024 are special in that normal users are not allowed to run servers on them.

There are several ways to solve this

1] Change the listening port greater that 1024,usually node server runs on 8080.

2] Run the server with root priviledge sudo node app.js

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 abhi patil