In Windows 10, how can we find out which applications reserved TCP port ranges as shown by netsh?
Recently in my development machine some TCP ports started being unavailable for applications, giving the error 10013.
Searching the internet I think that this explanation here is the most likely: the ports were administratively excluded by some application(s), most likely being reserved for their own use.
Indeed I can see the ranges of excluded ports with the command
netsh int ipv4 show excludedportrange protocol=tcp
I can also try to delete some excluded ranges, but mostly netsh refuses to do so, showing errors "access denied" (even inside an administrative shell) or "element not found".
So, now I would like to try another approach: find out which applications are excluding those TCP port ranges.
Although this is a corporate machine, it does not belong to a Windows domain (and indeed is in my house right now, as I'm working from home because of the pandemic).
So, that's the question: how can I find which applications are reserving those TCP port ranges ?
UPDATE
There are lots of questions about this in Stackoverflow (which I think is not the adequate place for this question, but anyway).
I found a solution somewhere that worked for me:
net start winnat
net stop winnat
It worked immediately, didn't even require a restart.
Windows 10 Pro 20H2 19042.804 Windows Feature Experience Pack 120.2212.551.0
Edit.
Output from netsh just now:
$ netsh int ipv4 show excludedportrange tcp
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
20092 20191
20192 20291
20292 20391
20392 20491
20492 20591
20592 20691
20792 20891
20892 20991
20992 21091
21092 21191
21192 21291
21292 21391
21393 21492
21493 21592
21593 21692
21693 21792
21793 21892
21893 21992
22033 22132
22133 22232
22233 22332
22637 22736
22737 22836
22837 22936
22937 23036
23037 23136
23137 23236
23237 23336
23360 23459
23460 23559
23560 23659
23660 23759
* - Administered port exclusions.
Solution 1:
It is usually caused by Hyper-V, Docker, or WSL. Try restarting winnat
:
net stop winnat
net start winnat
Also according to docker/for-win#3171 (comment). it happens when the dynamic port range on your machine is not updated to the new start port. You can fix this with:
netsh int ipv[46] set dynamic tcp start=49152 num=16384
Solution 2:
A very good tool to relate Port to Application is TCP View (which is a Microsoft SysInternals app).
Look for SysInternals, download TCP View, install it and run it. It will show you what you need.
Here is a screen shot .
In the Options section, you can uncheck (do not show) unconnected ports. That removes svchost, for example, and reduces some display clutter.