I attempted to run my web service through visual studio. I faced an issue like :
---------------------------
Microsoft Visual Studio
---------------------------
Reason for this error that is you give the wrong port number to your application.
just use http ports for your application to run
use the port near to 8080 number, i.e:
localhost:8090
to change the port for you application in visual-Studio
goto project properties > web > Server > ProjectUrl
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
Another application is using that port. This could help you
to summarize all the answers. There are 2 solutions. Both worked for me. - Solution #1 Kill the app that uses the same port. - Solution #2 Configure IIS Express to use a different port for your project.
Solution #1 (supposing the port in the error message was 443) Run in the command line:
netstat -ao | findstr 443
it returns: TCP 0.0.0.0:443 pe01:0 LISTENING 2904
The last number (thanks to @chris-schiffhauer) is PID to kill. Go to the Task Manager -> Processes -> [Show Processes From All users], Kill a process with PID=2904. In my case, it was VmWare host.
Solution #2
(Supposing message was: Failed to register URL "http://localhost:433/" for site "MyProject.Website0"...).
Open the folloing file in notedpad++: C:\Users\MY_USER_NAME\Documents\IISExpress\config\applicationhost.config
Find in it a line containing:
<site name="MyProject.Website0" id="...
...
<bindings>
<binding protocol="http" bindingInformation="*:80:localhost" />
<binding protocol="https" bindingInformation="*:443:localhost" />
</bindings>
Either change 433
to something else, like 4330
or delete the conflicting <binding.../>
tag.
Go to Web Project Properties >> Web >> Project Url >> Change port i.e: http://localhost:22345/ => http://localhost:22346/ Hope this help!
I ran into the same problem after we had upgraded a solution from Visual Studio 2012 to 2015. I had come here and ran netstat
only to find that no other application was using the same ports. It turns out I had the same sites with the same ports mapped in the applicationhost.config
at Users/<username>/Documents/IISExpress/config
and the applicationhost.config
in the .vs
folder inside my solution. I should note that the problem didn't start right after the upgrade either. It just start failing consistently one morning. A couple reboots didn't seem to solve the problem either.
Removing the conflicted sites from the one stored in my Documents and restarting Visual Studio solved the problem.