Description
openedon Jun 9, 2021
Problem encountered on https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/run#
Operating System: windows
I was getting the following error when running dotnet watch run
:
Unable to bind to http://localhost:5000 on the IPv4 loopback interface: 'An attempt was made to access a socket in a way forbidden by its access permissions.'.
I found this SO reply: https://superuser.com/a/1504618
Running the listed command (netsh interface ipv4 show excludedportrange protocol=tcp
) yielded several ranges which happened to overlap with port 5000. Changing the port in launchSettings.json
allowed the watch command to run as expected.
The specific ranges seems to be different for every system that runs that command.
If there a way to free up these ports locally so that the tutorial can be run without modification? Alternatively, could the tutorial be changed to use a port that is not going to be reserved by Windows?
Some additional important, but less relevant questions:
Are there port ranges that are guaranteed NOT to be reserved at random by Windows?
Is the set of reserved port ranges meant to differ between systems? If so, why, and how does it pick the ranges?