8

Everytime I try to debug my asp.net website I get this error:

Unable to launch the IIS Express Web server.

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

In eventviewer I noticed this error in the log:

The worker process for app pool 'Clr4IntegratedAppPool', PID='13248', failed to initialize the http.sys communication when asked to start processing http requests and therefore will be considered ill by W3SVC and terminated. The data field contains the error number.

I assume this means my Clr4IntegratedAppPool does not have enough rights? How can I fix thi?

user2657943
  • 2,598
  • 5
  • 27
  • 49
  • 1
    Try the below: running visual studio as admin, Try changing port number. Ensure that you are running it only once, sometimes running 2 Solutions including the same project might cause this issue as well, coz you might be trying to run same project more than once – Dilip May 02 '18 at 09:50

7 Answers7

11

One reason for the IIS Express being unable to start properly can be that the port it wants to use is reserved. The port you want to use will not show up in netstat -an | findstr <your port number> if it is not in use.

You can either change the port you use or remove the reservation.

View reservations (elevated command prompt): netsh int ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
        80          80
       443         443
     50000       50059     *

* - Administered port exclusions.

You can remove the reserved range if it is not in use with netsh int ipv4 delete excludedportrange protocol=tcp startport=50000 numberofports=60. Should reply Ok. If you get Access denied. it is because the range is currently in use. You will have to shut down the program that use the ports in order to create a reservation that intersects with the range.

If you want to create the range again, use netsh int ipv4 add excludedportrange protocol=tcp startport=50000 numberofports=60.

I had this problem because I recently installed Hyper-V and Docker and my IIS Express threw error events in my event log with ID 2269:

The worker process for app pool 'Clr4IntegratedAppPool', PID='12345', failed to initialize the http.sys communication when asked to start processing http requests and therefore will be considered ill by W3SVC and terminated. The data field contains the error number.

And subsequently 2276:

The worker process failed to initialize correctly and therefore could not be started. The data is the error.

Source of my solution: Docker for Windows – Port Reservations | Developer Musings

Heki
  • 926
  • 2
  • 15
  • 34
  • this fixed my problem. i found the port i was using in the reserved list, and changed the project url port in the project config to one that was outside of those reserved ranges. – Stefanvds Jul 19 '23 at 02:49
3

I had exactly the same problem with VS2017 / IIS Express 10. Tried a few tips & tricks found at forums, but the only one that really fixed the bug definitively is the following:

  1. Close all Visual Studio instances and IIS Express (if it's running)
  2. Go to Windows' "Programs and Resources", find IIS Express in the list of installed programs, and "Uninstall" it
  3. Restart your computer, just be sure that all processes are closed
  4. Download IIS Express 10 standalone installer from Microsoft: https://www.microsoft.com/en-us/download/details.aspx?id=48264
  5. Install it, open Visual Studio, and it should work fine.
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
1

If you cannot find your solution for this, try this:

  1. Enter Windows + R & type Regedit
  2. Go to the following path:

    Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
    
  3. Change the value of name Start from 4 to 3.

    Change Start from 4 to 3

KyleMit
  • 30,350
  • 66
  • 462
  • 664
An Lê
  • 11
  • 1
  • can you explain what this is doing? – Jared Beach Dec 07 '20 at 18:37
  • 1
    @JaredBeach Start 4 is "Deactivated". 3 is "Manual". And for completeness, 2 is "Automatic" and 1 is "Automatic (delayed)". Manual should be read as "on request", really. – Heki Feb 09 '21 at 09:25
0

"The process cannot access the file because it is being used by another process" usually means that there is something else already listening on that port. Maybe you started the same application twice?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55
  • There's no other application using that port; I've verified with `netstat -ao` as well as through the Resource Monitor. I've checked all the IIS Express configs. Nothing is misconfigured. This error is baffling. It seems a machine reboot is the only thing that fixes it. – crush Jul 25 '19 at 15:24
  • I also used netstat and resmon to see if anything was listening on that port. Nothing was. I tried to increment the port number, but same error. Eventually I tried some completely different port, and this worked. I either suspect something like Docker has reserved the port or that the build processes start an intermediate port that somehow conflicts with itself. – Peheje Jul 23 '20 at 13:33
  • Likely a reserved port. See my answer for details. – Heki Feb 09 '21 at 12:54
0

Ensure the service Application Host Helper Service (AppHostSvc) is running. Also ensure that Host Network Service (hns) is running.

Some ASP.NET websites might also require ASP.NET State Service (aspnet_state) to be running.

Jared Beach
  • 2,635
  • 34
  • 38
0

This worked for me:

  1. Restore bypass traverse checking rights (see ref)

I only did #2 because the privileges I had were correct already.

  1. Restart the W3SVC and HTTP services To restart the W3SVC and HTTP services by using the net command:

Open an elevated Command Prompt window. Click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator. Type:

net stop w3svc
net stop http
net start w3svc
net start http

Ref: https://social.technet.microsoft.com/wiki/contents/articles/21750.event-id-2269-iis-worker-process-availability.aspx

Marcus
  • 8,230
  • 11
  • 61
  • 88
0

This happened for me when I opened an old solution with VS2019. None of the answers here worked for me. So I chose a different approach.

I created a new ASP.NET solution and saw which port is it using. it was using 61384.

Then I closed my solution and opened the .sln file and change the port.

After reloading the solution, it worked.

enter image description here

FLICKER
  • 6,439
  • 4
  • 45
  • 75