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

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.

3

10 Answers

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:

General workround (in comment 554587817):

Fast workround: choose a port that not belong to reserved ranges

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.

10

kudos to @fambrosi to find the thread and . 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
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.

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
1

Adding to the growing list of things that might be the issue: I was using ExpressVPN on my computer, this somehow interfered with binding any localhost port. Uninstalling + restarting fixed the issue for me!

1

Restart was not enough! The only way to solve the problem is by the following:

You have to kill the service which run at that port.

At cmd, run as admin, then type :

netstat -aon | find /i "listening"

Then you will get a list with the active service, search for the port that is running at 4200 and use the process id which is the last column to kill it by:

taskkill /F /PID 2652

Same issue for me, triggered by running Vue dev server on port 3000. In my case, I wanted to browse to localhost:3000 via a custom host-mapped local domain name (e.g. mysite.dev) instead, so I incorrectly set my local Apache configuration to listen on 0.0.0.0:3000 and defined <VirtualHost *:3000>. So Apache was already using the port.

I recently updated my docker to the latest version and my angular application started giving me this error. After investigating I found that port 4200 (the default port which angular applications use) is occupied by other applications.

I ran the application with a different port and solved the problem.

ng serve --port 4000

If the above answers don't fix your issue, your port could be bound via netsh. You can use the following command to see if your port proxies information to elsewhere; I had bound port 3000 to another ip and received this error as a result.

netsh interface portproxy show all 

If you do have the port bound, you can remove the port binding with:

netsh interface portproxy listenport=(your port) listenaddress=(ip address)

You Might Also Like