It was a bug I faced something like year ago, and I didn’t fixed that in the past. This time issue was exactly the same (though app was different).
ng serve Port 4200 is already in use. Use '--port' to specify a different port.
ok let’s check whether anything is blocking the port.
Let’s call netstat in cmd with admin rights:
netstat -ano | findstr 4200
there is no service using that port… strange.
I was close to surrender again, and change port of the app, but I started googling and meet this great article:
As it turned out there Windows makes port reservations in range 1025-65534. This is especially visible if you’re working in configuration: Win 10 + Hyper-V + Docker for Windows.
How to fix it?
Check whether your port is in excluded range by running:
netsh int ipv4 show excludedportrange tcp Protocol tcp Port Exclusion Ranges Start Port End Port ---------- -------- 4137 4367 9800 9800 9801 9801 49671 49770 61902 62001
if your port is in that range, best solution would be to :
1. Disable Hyper-V
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
2. Reserve the port for your app
netsh int ipv4 set dynamic tcp startport=4200 numberofports=1
3. Enable Hyper-V
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
Some people need to run also that command
reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f
as described in this github issue .