23

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
  • 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? – Biswapriyo May 16 '19 at 20:21
  • 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. – Nacho Vazquez Calleja May 16 '19 at 20:26
  • I uninstall Ubuntu and installed Debian and the problem continues – Nacho Vazquez Calleja May 16 '19 at 20:49

11 Answers 11

21

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.

9
  • 1
    You saved my day by restarting windows twice. – Mohsen Esmailpour Oct 13 '19 at 12:36
  • 2
    I'm glad to have helped you. It is not a pretty answer, but it is not a pretty problem neither. – Nacho Vazquez Calleja Oct 13 '19 at 13:13
  • 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. – Barnaba May 26 '20 at 13:41
  • it fixed my issue (happened after i did windows updates) – CMS Jun 25 '20 at 15:39
  • This fixed my issue also – ZECTBynmo Feb 16 at 13:59
18

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

1
  • 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'. – Alexander Riccio May 19 at 20:34
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.

2

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
  • 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. – Shizan Bhat Feb 6 '20 at 12:46
2

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
  • Indeed. To fix the issue: disconnect VPN Express & reconnect again. – roland Nov 17 '20 at 21:01
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
0

I've had this same issue and went into Task Manager and killed all of the Node Servers that were running and the issue went away.

0

In my case I was using IIS (internet service manager) I added there a website with a bond using the port 4200, after changing this to another port the issue gone away :)

0

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
0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.