silent_coder
silent_coder

Reputation: 6522

run node.js webbapp on 80 port on windows

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

Upvotes: 19

Views: 26088

Answers (6)

El Bachir
El Bachir

Reputation: 121

@CAMD_3441 's extremely useful answer allowed me to launch the SignallingWebServer of my Unreal Engine 5 Pixel Streaming App.

I couldn't get SWS to use (listen) to port 80 and it was giving me this error :

node:events:371 throw er; // Unhandled 'error' event ^ Error: listen EACCES: permission denied 0.0.0.0:80 at Server.setupListenHandle [as _listen2] (node:net:1288:21)

All I had to do to fix that issue was type net stop http, and enter yes.

My SWS was able to launch on port 80 and I was able to view the Pixel Streaming page on 'localhost' using the browser which wasn't working if I connected the SWS to another port beside 80.

Upvotes: 0

CAMD_3441
CAMD_3441

Reputation: 3164

I had this issue also on my 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:

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

enter image description here

I clicked ok to close it and just typed localhost on my browser and my app launched!

What is weird is that I went back to the TaskManager -> Services tab, and I restarted all four services that were stopped. In the screen shot below you can see one of the services that was stopped before (look at the Description column), but now restarted:

enter image description here

But now when I run npm start my node app does get launched still.

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.

Upvotes: 2

Rich Hildred
Rich Hildred

Reputation: 41

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.

Upvotes: 0

Jimme
Jimme

Reputation: 11

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...

Upvotes: 1

Serhii Kuts
Serhii Kuts

Reputation: 449

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.

Upvotes: 4

Ph0en1x
Ph0en1x

Reputation: 10067

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.

Upvotes: 23

Related Questions