Question

I have a project which perfectly works in WebStorm on windows. When trying the same on Mac, I got EACCES error trying https with default (443) port

Playing around, I noticed that running

sudo node app.js 

works nice. Doing the same without sudo throws EACCES. And I cannot run project from WebStorm, because it runs node without sudo access

Of course, trying any higher port (e.g. 3000) works perfectly. But I work for a while and all environments need 443 port in this case.

I understand that it's something with admin permissions. Any way to make it working when run within my IDE? Something like "always run node as an admin"? I'm new to Mac, so have no idea how to do that.

Exception looks like:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:904:11)
    at Server._listen2 (net.js:1023:19)
    at listen (net.js:1064:10)
    at Server.listen (net.js:1138:5)
    at Object.startServer (/Users/xxxxxx/trunk/server.js:112:21)
    at init (/Users/xxxxxx/trunk/app.js:12:12)
    at Object.<anonymous> (/Users/xxxxxx/trunk/app.js:15:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

Just in case, code to start server:

  var options = {
    key: fs.readFileSync("./server/certificate/xxxxxx.key").toString(),
    cert: fs.readFileSync("./server/certificate/xxxxxx.cert").toString()
  };

  var securedServer = https.createServer(options, function (req, res)
  {
    app.handle(req, res);
  });

  securedServer.listen(config.securePort); //443 in this case

Again, this code works both in windows and in mac with root access. So, it's not the reason of the issue.

Your help is very appreciated!

Was it helpful?

Solution

Submitted request to enable running node.js from WebStorm as sudo: http://youtrack.jetbrains.com/issue/WEB-11972

Meanwhile, running app at a different port on Mac and configured port forwarding as:

sudo ipfw add 101 fwd 127.0.0.1,8443 tcp from any to me 443

OTHER TIPS

I can suggest using port forwarding. Please see https://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user for possible workarounds Another possible way to do this is running WebStorm itself as sudo...

Anyway, please feel free to file a request for a possibility to run node as sudo to youtrack, http://youtrack.jetbrains.com/issues/WEB

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top