I attempted to run my web service through visual studio. I faced an issue like :
---------------------------
Microsoft Visual Studio
---------------------------
I had a similar issue when trying to run a project from Visual Studio 2019 on Windows 10.
The application could not start because the port was apparently being used by another process. However, the netstat command showed that the port was not being used by any application.
After spending 2-days Googling I found a solution that worked for me. The port I was trying to use was in the excluded port range which you can see by running the command:
netsh interface ipv4 show excludedportrange protocol=tcp
The culprits that reserved these ports in my case were Docker for Windows and Hyper-V
The Solution
I uninstalled Docker (as I did not need it) and disabled Hyper-V. To disable Hyper-V: Go to: Control Panel-> Programs and Features-> Turn Windows features on or off. Untick Hyper-V and restart the computer.
After the restart the command
netsh interface ipv4 show excludedportrange protocol=tcp showed no ports reserved.
I then added the port for my application to the excluded port range by running the following command from an elevated command line:
netsh int ipv4 add excludedportrange protocol=tcp startport=50403 numberofports=1 store=persistent
Then I reenabled Hyper-V (Docker can be reinstalled if needed) and restarted the computer again.
Hyper-V now reserved its ports without interfering with the port used by my application: Reserved Port Ranges