How to fix `listen EACCES: permission denied` on any port
Solution 1
One Windows restart isn't enough, I restarted twice and the problem is gone.
Sorry, I don't have anything more technical.
Except: 1: Try not to develop on WSL from a Windows folder.
Solution 2
In my case the error appears because the port used belong to reserved ports for Hyper-V.
This port range changes when I restart my computer, so sometimes I get the error sometimes no.
To check reserved ports by windows you can use(cmd/powershell):
netsh interface ipv4 show excludedportrange protocol=tcp
The issue is described in: https://github.com/microsoft/WSL/issues/5514
General workround (in comment 554587817): https://github.com/docker/for-win/issues/3171#issuecomment-554587817
Fast workround: choose a port that not belong to reserved ranges
Solution 3
kudos to @fambrosi to find the thread and https://github.com/docker/for-win/issues/3171#issuecomment-788808021. Here is the command to solve this annoying issue.
net stop winnat
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384
net start winnat
Solution 4
For me it was that node is listening on the wrong network interface.
After using docker it was using the docker network interface as primary.
Disabling the network interface to force node to use the correct interface did the trick.
Solution 5
I also Faced the same issue while trying ng serve
command on the terminal.
an unhandled exception occurred: listen EACCES: permission denied 127.0.0.1:4200
see "C:\Users\MyUser\AppData\Local\Temp\ng-At4Tad\angular-errors.log" for further details.
Solution: Simply modify the command as
ng serve --port 4401
Related videos on Youtube
Nacho Vazquez Calleja
Updated on September 18, 2022Comments
-
Nacho Vazquez Calleja over 1 year
Has anyone experienced something liked this with node:
I was running
Angular
, my Windows crashed and restarted and now when I tryng serve
I'm getting:Error: listen EACCES: permission denied 127.0.0.1:4200 at Server.setupListenHandle [as _listen2] (net.js:1253:19) at listenInCluster (net.js:1318:12) at GetAddrInfoReqWrap.doListen [as callback] (net.js:1451:7) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
I also tried
ng serve --port 4201
Same result.
NOTE: Before Windows restarted I was running the app in
WSL
. After, I triedWSL
andPowershell
.Update: It is even happening with a new project.
-
Admin about 5 yearsTry to uninstall and reinstall the whole WSL distro and redo all the steps. Or redo the steps in a newer distro install. Does this also occurs?
-
Admin about 5 yearsI'll try that. Right now, I already reinstalled node on Windows and check if the port was being used, it is not. Thanks for the advice, let you know if it worked.
-
Admin about 5 yearsI uninstall
Ubuntu
and installedDebian
and the problem continues
-
-
Mohsen Esmailpour over 4 yearsYou saved my day by restarting windows twice.
-
Nacho Vazquez Calleja over 4 yearsI'm glad to have helped you. It is not a pretty answer, but it is not a pretty problem neither.
-
Shizan Bhat over 4 yearsC:\Users\MyUser\Desktop\AngularExample>ng serve --port 4401 10% building 3/3 modules 0 activei 「wds」: Project is running at localhost:4401/webpack-dev-server i 「wds」: webpack output is served from / i 「wds」: 404s will fallback to //index.html ** Angular Live Development Server is listening on localhost:4401, open your browser on localhost:4401 ** i 「wdm」: Compiled successfully.
-
Barnaba almost 4 yearsThis has also helped me with my EACCES that wasn't related to node (and I don't even think it was WSL related, but I use WSL). When in doubt try turning it off and on again twice.
-
CMS almost 4 yearsit fixed my issue (happened after i did windows updates)
-
roland over 3 yearsIndeed. To fix the issue: disconnect VPN Express & reconnect again.
-
ZECTBynmo over 3 yearsThis fixed my issue also
-
Anurag Phadnis about 3 yearsDon't know how but it worked.
-
Ali80 about 3 yearsThis was one of stupidest solutions I've ever heard, yet it worked! many thanks
-
Prakash S almost 3 yearsAha! This might be the problem for me too. 3000 is in that range. I wish there was a better error than access denied, since we tend to associate that with 'port in use', not 'port reserved'.
-
kissu almost 3 yearsThe "double-restart" is probably because Windows did not stopped the first time because of the "fast startup" feature being enabled by default. More details here: howtogeek.com/349114/… Restarting twice did a real shutdown IMO.
-
zero8 almost 3 yearsA process is running. check you port use taskkill
-
Marc Sances over 2 yearsI used to fix this issue restarting Windows, but it would come back eventually. The
netsh interface ipv4 show excludedportrange protocol=tcp
is great for diagnosis, and eventually the bunch of netsh dynamic tcp commands fixed it. -
Ioan Bucur over 2 yearsJust stopping and restarting worked for me. Thanks!
-
Michael Freidgeim over 2 yearsSimilar answer from <Node.js EACCES error when listening on most ports> and article medium.com/@Bartleby/…
-
Admin about 2 yearsthis actually worked for me