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

Solution 1:

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 2:

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 3:

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 4:

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