Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unable to launch the IIS Express Web server." in Visual Studio

I attempted to run my web service through visual studio. I faced an issue like :

---------------------------
Microsoft Visual Studio
---------------------------
Unable to launch the IIS Express Web server.

Failed to register URL "http://localhost:63591/" for site "xxxxxx" application
"/". Error description: The process cannot access the file because it is being
used by another process. (0x80070020)

---------------------------
OK   
---------------------------

I saw the task manager and found that PID 4 is used by System and its Description is NT Kernel & System. So I tried to stop the http service. All dependency services stopped. But I am facing an issue in stopping http service like

The service is starting or stopping.  Please try again later.

So, I tried to stop and start the service manually. But the End process is disabled. It will be helpful if anyone could help with this issue

like image 395
Priya Avatar asked Oct 20 '22 21:10

Priya


People also ask

How do I enable IIS Express in Visual Studio?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.

How do I open IIS Express in Visual Studio 2015?

1) In Solution Explorer, right click the your project and click Properties. 2) In the left tab, click Web. 3) Select IIS Express, check out your Project Url, then create Virtual Directory.


2 Answers

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

like image 200
Philip Trenwith Avatar answered Oct 23 '22 11:10

Philip Trenwith


From https://www.davidsalter.co.uk/unable-to-launch-the-iis-express-web-server-error-0x80070020/

Error code 0x80070020 means ERROR_SHARING_VIOLATION, which in the case of IIS Express (or IIS) means that the port that it is attempting to listen on is being used by another process.

Use the netstat command to find out which application is using the port.

netstat -ao | findstr <port_number_to_search_for>

The a parameter tells netstat to display all connections and listening ports.

The o parameter tells netstat to display the process ID associated with the connection.

Running the above netstat command will produce output such as:

C:\>netstat -ao | findstr 4026
TCP    12.0.0.1:4026        cs-pc:4026         LISTENING       9544

The last number displayed (9544 here) is the process ID.

like image 176
Chris Schiffhauer Avatar answered Oct 23 '22 09:10

Chris Schiffhauer