The Computer Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping

--

Chapters
00:00 How To Fix `Listen Eacces: Permission Denied` On Any Port
00:40 Accepted Answer Score 26
00:59 Answer 2 Score 4
01:16 Answer 3 Score 3
01:34 Answer 4 Score 39
02:09 Thank you

--

Full question
https://superuser.com/questions/1437780/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windowssubsystemforlinux #nodejs #npm

#avk47



ANSWER 1

Score 39


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




ACCEPTED ANSWER

Score 26


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.




ANSWER 3

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




ANSWER 4

Score 3


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