How to fix `listen EACCES: permission denied` on any port

88,689

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
Share:
88,689

Related videos on Youtube

Nacho Vazquez Calleja
Author by

Nacho Vazquez Calleja

Updated on September 18, 2022

Comments

  • Nacho Vazquez Calleja
    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 try ng 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 tried WSL and Powershell.

    Update: It is even happening with a new project.

    • Admin
      Admin about 5 years
      Try 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
      Admin about 5 years
      I'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
      Admin about 5 years
      I uninstall Ubuntu and installed Debian and the problem continues
  • Mohsen Esmailpour
    Mohsen Esmailpour over 4 years
    You saved my day by restarting windows twice.
  • Nacho Vazquez Calleja
    Nacho Vazquez Calleja over 4 years
    I'm glad to have helped you. It is not a pretty answer, but it is not a pretty problem neither.
  • Shizan Bhat
    Shizan Bhat over 4 years
    C:\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
    Barnaba almost 4 years
    This 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
    CMS almost 4 years
    it fixed my issue (happened after i did windows updates)
  • roland
    roland over 3 years
    Indeed. To fix the issue: disconnect VPN Express & reconnect again.
  • ZECTBynmo
    ZECTBynmo over 3 years
    This fixed my issue also
  • Anurag Phadnis
    Anurag Phadnis about 3 years
    Don't know how but it worked.
  • Ali80
    Ali80 about 3 years
    This was one of stupidest solutions I've ever heard, yet it worked! many thanks
  • Prakash S
    Prakash S almost 3 years
    Aha! 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
    kissu almost 3 years
    The "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
    zero8 almost 3 years
    A process is running. check you port use taskkill
  • Marc Sances
    Marc Sances over 2 years
    I 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
    Ioan Bucur over 2 years
    Just stopping and restarting worked for me. Thanks!
  • Michael Freidgeim
    Michael Freidgeim over 2 years
  • Admin
    Admin about 2 years
    this actually worked for me