run node.js webbapp on 80 port on windows

2019-02-16 08:03发布

I need to make my local node.js webapp listen 80 port. Now if run my app on port 80 I get this erro

events.js:72
        throw er; // Unhandled 'error' event
          ^
Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1127:5)
    at Object.<anonymous> (\scripts\server.js:23:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10) 

And if run app on 4321 port this error do not reproduced, so it's port depending.

What should I do to be able run my app on port 80 on Windows 7

4条回答
2楼-- · 2019-02-16 08:04

IIS on 80 port is definitely issue. And instead of turning it of you can try IIS node. http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx Probably you don't need port 80 in local development at all, but if you go in production on Windows machine IIS Node is good choice to load balance.

查看更多
甜甜的少女心
3楼-- · 2019-02-16 08:22

Sigh - i just found out that SKYPE.EXE was lurking on my ports 80 and 443. Use netstat -anb to see what might be blocking node.exe from accepting sockets on those ports...

查看更多
三岁会撩人
4楼-- · 2019-02-16 08:27

On windows machine you 80 port probably busy with IIS Server. Try to stop iis first and after run node.js webapp with port 80.

查看更多
何必那么认真
5楼-- · 2019-02-16 08:27

Like @jimme my problem was because I installed skype client for testing another project on the same development machine.

In my case I could }).listen(80); but not }).listen(80, "0.0.0.0"); My server was unreachable from anything but localhost. When I investigated by doing netstat -abn I could see that something was listening on that port but there was no process information. I lucked upon the info that "Windows attempts to accommodate such inflexible services by not binding its dispatch mechanism to port 80 until something actively asks for that. (This is why you won't necessarily see a problem initially, but can run into this issue after some sort of update or config change.)," at https://serverfault.com/questions/65717/port-80-is-being-used-by-system-pid-4-what-is-that which pointed to the article https://www.mikeplate.com/2011/11/06/stop-http-sys-from-listening-on-port-80-in-windows/.

When I saw that important piece of information and @jimme 's answer I remembered that I had also installed skype. I just made skype not start at startup and I was good.

查看更多
登录 后发表回答