简体   繁体   English

在Windows的80端口上运行node.js webbapp

[英]run node.js webbapp on 80 port on windows

I need to make my local node.js webapp listen 80 port. 我需要使本地node.js webapp监听80端口。 Now if run my app on port 80 I get this erro 现在,如果在端口80上运行我的应用程序,则会出现此错误

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. 如果在4321端口上运行应用程序,则不会重现此错误,因此取决于端口。

What should I do to be able run my app on port 80 on Windows 7 我应该怎么做才能在Windows 7的80端口上运行我的应用程序

On windows machine you 80 port probably busy with IIS Server. 在Windows计算机上,您的80端口可能正忙于IIS服务器。 Try to stop iis first and after run node.js webapp with port 80. 尝试先停止iis,然后在使用端口80运行node.js webapp之后停止。

IIS on 80 port is definitely issue. IIS在80端口上绝对是问题。 And instead of turning it of you can try IIS node. 而且,您可以尝试IIS节点来代替关闭它。 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. http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx也许您根本不需要在本地开发中使用端口80,但是如果您在Windows计算机上投入生产,则IIS Node是进行负载平衡的好选择。

叹气-我刚刚发现SKYPE.EXE潜伏在我的端口80和443上。使用netstat -anb查看是什么阻止了node.exe接受那些端口上的套接字...

Like @jimme my problem was because I installed skype client for testing another project on the same development machine. 像@jimme一样,我的问题是因为我安装了Skype客户端,以便在同一台开发计算机上测试另一个项目。

In my case I could }).listen(80); 就我而言,我可以}).listen(80); but not }).listen(80, "0.0.0.0"); 但不是}).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. 当我通过netstat -abn进行调查时,我看到该端口上正在监听某些内容,但是没有进程信息。 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/ . 我很幸运地看到这样的信息:“ Windows尝试通过在主动请求该端口之前将其分发机制绑定到端口80来绑定这种灵活的服务。(这就是为什么您最初不一定会看到问题,但是会遇到此问题的原因。进行某种更新或配置更改后)。”, 网址https://serverfault.com/questions/65717/port-80-is-being-used-by-system-pid-4-what-is-转到文章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. 当我看到重要信息和@jimme的答案时,我想起我也安装了Skype。 I just made skype not start at startup and I was good. 我只是让skype在启动时不启动,所以我很好。

I had this issue also on my Windows 10 PC. 我的Windows 10 PC上也有此问题。

I followed the command on this link ( net stop http ): https://stackoverflow.com/a/16243333 in a Command Prompt that I opened up as administrator and got this output: 我在以管理员身份打开的命令提示符中关注了此链接( net stop http )上的命令: https ://stackoverflow.com/a/16243333,并获得了以下输出:

C:\Users\<user>\Documents\project>net stop http 

The following services are dependent on the HTTP Service service. Stopping the HTTP Service service will also stop these services.

 World Wide Web Publishing Service    
 SSDP Discovery    
 Print Spooler    
 Function Discovery Provider Host

Do you want to continue this operation? (Y/N) [N]: y 

The World Wide Web Publishing Service service is stopping. 
The World Wide Web Publishing Service service was stopped successfully.

The SSDP Discovery service is stopping. 
The SSDP Discovery service was stopped successfully.

The Print Spooler service is stopping. 
The Print Spooler service was stopped successfully.

The Function Discovery Provider Host service is stopping. 
The Function Discovery Provider Host service was stopped successfully.

The HTTP Service service was stopped successfully.

C:\Users\<user>\Documents\project>

I then did npm start again on another command prompt where I'm not running it as Administrator, and got this Error Dialogue 然后,我在另一个命令提示符处(不是我以管理员身份运行)再次使npm start ,并收到此错误对话框

在此处输入图片说明

I clicked ok to close it and just typed localhost on my browser and my app launched! 我单击确定将其关闭,然后在浏览器中键入localhost并启动了我的应用程序!

What is weird is that I went back to the TaskManager -> Services tab , and I restarted all four services that were stopped. 奇怪的是,我回到TaskManager-> Services选项卡 ,然后重新启动了所有已停止的四个服务。 In the screen shot below you can see one of the services that was stopped before (look at the Description column), but now restarted: 在下面的屏幕快照中,您可以看到以前已停止的一项服务(请查看“描述”列),但现在已重新启动:

在此处输入图片说明

But now when I run npm start my node app does get launched still. 但是现在当我运行npm start我的节点应用程序仍然可以启动。

So it does seem a little weird for me, that before I stopped those services I couldn't launch my app. 因此,对我来说似乎有点奇怪,在我停止这些服务之前,我无法启动我的应用程序。 After stopping them I now can launch my app. 停止它们后,我现在可以启动我的应用程序。 But I can still launch my app even after restarting those services. 但是即使重新启动这些服务,我仍然可以启动我的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM