Error: listen EACCES 0.0.0.0:443

Issue

I am trying to run a web project by NodeJS on my MacOS.

After npm install, npm start returns an error

events.js:183
  throw er; // Unhandled 'error' event
  ^

Error: listen EACCES 0.0.0.0:443
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at Server.setupListenHandle [as _listen2] (net.js:1334:19)
    at listenInCluster (net.js:1392:12)
    at Server.listen (net.js:1476:7)
    at Object.<anonymous> (/Users/softtimur/Startup/PRODSERVER/tmp/WeCard/models/www:36:8)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

No other website is running on my Mac.

Does anyone know what’s wrong? Do I need to configure something on my Mac?

Edit 1:

sudo npm start returns

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::443
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at Server.setupListenHandle [as _listen2] (net.js:1351:14)
    at listenInCluster (net.js:1392:12)
    at Server.listen (net.js:1476:7)
    at Object.<anonymous> (/Users/softtimur/Startup/PRODSERVER/tmp/WeCard/models/www:36:8)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Solution

In order to listen on privileged ports you need root permissions to start the server; this applies to ports < 1024. You may use nginx as a reverse proxy server running on 443 and run your Node JS server alongside on non-privileged ports as an unprivileged user.

For more information on setting up Node JS application with nginx in production, follow the link:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-centos-7

Answered By – Abhishek Singh

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published