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

Visual StudioIis Express

Visual Studio Problem Overview


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

Visual Studio Solutions


Solution 1 - 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

Solution 2 - Visual Studio

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.

Solution 3 - Visual Studio

Solution that worked from me is,

To fix this you must temporarily disable the winnat service, this is simply done by running this command (must be run as administrator)

net stop winnat

Start your docker services and start winnat again

net start winnat

Solution posted at http://www.herlitz.nu/2020/12/01/docker-error-ports-are-not-available-on-windows-10/

Solution 4 - Visual Studio

I had the same problem. I just restarted Visual Studio and it worked.

Solution 5 - Visual Studio

I had the same Issue. As @Kautsky Lozano mentions above Another application is using that port.

So [for a Windows OS] just:

  • Open Resource Monitor (Task Manager -> Performance -> Open Resource Monitor )
  • Click on the Network tab.
  • And at TCP Connections find the application that uses the Local Port that IIS Express uses and close it. (it was firefox on my case)

Solution 6 - Visual Studio

If netstat doesn't show anything already using the port

netstat -ano | findstr <your port number>

The port might be excluded, try this command to see if the range is blocked by something else:

netsh interface ipv4 show excludedportrange protocol=tcp

You can try to unblock the range from the start port for a number of ports (need Command Prompt with Administrator):

netsh int ip delete excludedportrange protocol=tcp numberofports=<number of ports> startport=<start port>

For me I couldn't unblock these, I just got "Access is denied", so I ended up having to pick another port for my site.

Solution 7 - Visual Studio

After updating Windows 10 and/or Visual Studio 16+ it might happen due to an internal bug that IISExpress fails to register any development website because it no longer accepts localhost connections.

To fix the issue, you just have to register again the binding. To do so, run from an administrative shell the following command:

netsh http add iplisten ipaddress=:: 

Solution 8 - Visual Studio

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.

Solution 9 - Visual Studio

IIS Express Failing to Start Solution in Visual Studio

  • Go to Task Manager
  • Search for "Application Frame Host" Process
  • End this Process
  • Try to Run Again

If not successful, Try run this command in cmd: "net stop winnat"

Solution 10 - Visual Studio

This Answer Work For Me
1-open cmd with Run As Administrator
2-type net stop winnat
you got
"The Windows NAT Driver service was stopped successfully."
3- then type net start winnat
you got
The Windows NAT Driver service was started successfully.
after that go to visual studio and press ctrl+f5

Solution 11 - Visual Studio

In my case, doing the following did the trick:

  • Delete the Site from .vs<sitename>\config\applicationhost.config
  • Delete the Site from Documents\IISExpress\config\applicationhost.config
  • Delete the IISUrl from the .csproj

When I restarted Visual Studio, it assigned the project a completely new port number and ran perfectly

Solution 12 - Visual Studio

I just had this issue even though netstat did not show any conflicts.

The following fixed it for me:

  1. Close Visual Studio
  2. Open up File Explorer
  3. Navigate to the folder of the offending project
  4. Delete the obj and bin folders
  5. Delete the *.user file (this is probably optional)
  6. Restart Visual Studio and try again

Solution 13 - Visual Studio

I had this problem when upgrading an MVC project. I copied over the newer-MVC .csproj over my existing .csproj file then worked back to a fully working Project. What I failed to consider is the existing port number in the old .csproj. The new project had a new port number, yet shared the Project/Assembly Name. That was enough to make IIS Express lose its mind and throw this exception.

Just digging the old port number out of git and changing the IIS Express URL to include it in Project Settings was enough to fix it.

Solution 14 - Visual Studio

  1. Close visual studio
  2. delete ".vs" folder
  3. Try change port "localhost:8080"

It worked for me.

Solution 15 - 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

Solution 16 - Visual Studio

This indeed happened after installing Docker.

Steps to Resolve:

  1. Checked Network under Resource Monitor:

    • Port 66666 was not being used by any network process.
  2. Tried to Quit Docker Desktop:

    • Port 66666 still not available.
  3. Checked excluded port range: netsh interface ipv4 show excludedportrange protocol=tcp

    • Port is indeed in the Exclusion Ranges.
  4. Try to Untick Hyper-V in Turn Windows Features On and Off:

    • Cannot Find Hyper-V in Turn Windows Features On and Off.
  5. Attempted to remove Port from the Exclusion Ranges:
    netsh int ipv4 add excludedportrange protocol=tcp startport=66666 numberofports=1 store=persistent

    • Failed with result Element Not Found
  6. Inspired by this link to attempt to restart network services:

    1. net stop winnat
      • after running this command, confirmed port 66666 already disappeared from Exclusion Ranges by running netsh interface ipv4 show excludedportrange protocol=tcp
    2. stopped other network services just to be more assured
      • net stop LanmanWorkstation
      • net stop WlanSvc
      • net stop WwanSvc
    3. restart the network services
      • net start WwanSvc
      • net start WlanSvc
      • net start LanmanWorkstation
      • net start winnat
  7. Confirmed unavailable port is available now:

    1. netsh interface ipv4 show excludedportrange protocol=tcp
      • Port 66666 no longer in the Exclusion Ranges
    2. IIS Express Web Server can be launched successfully.
  8. Launched Docker Again:

    • port 6666 still available to be used.

Hope this helps anyone.

Solution 17 - Visual Studio

The easiest first pass at this without getting into the command console is to just shut down all applications (including VS), then launch VS by itself and try it again. There is likely another application like your browser causing the conflict. In my case Chrome caused it and was solved when shutting everything down and restarting VS. I opened Chrome again and everything was fine.

The netstat stuff above is useful, but to me that's only if you can't do what I'm suggesting.

Solution 18 - Visual Studio

Go to Web Project Properties >> Web >> Project Url >> Change port i.e: http://localhost:22345/ => http://localhost:22346/ Hope this help!

Solution 19 - Visual Studio

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.

Solution 20 - Visual Studio

I was able fix this problem by removing everything from <site> to </site> tags in

Users/<username>/Documents/IISExpress/config/applicatiohost.config file

<sites>
  <site>
     .
     .   ===> remove this content including the <site> and </site> tags.
     .
  </site>
</sites>

Solution 21 - Visual Studio

Port numbers do not match

In my case the problem was in my Bindings Tags found in the config file in .vs under my solution folder, the port numbers did not match. The bindings were as follows

<bindings>
     <binding protocol="http" bindingInformation=":16433:localhost" />
</bindings>

And in my settings i had url set as http://localhost:1943/

So what i did was to delete inside binding and run my web app, then it generated new binding with a different number then i copied the new generated port to my settings, then the error went away.

Solution 22 - Visual Studio

I ran into this problem in Visual Studio 2019 today and spent 3 hours before finally figuring out the problem. Visual Studio uses 2 files to track the SSL port number, so you have to fix both and you have to fix both while Visual Studio is closed. The two files are the applicationhost.config file that is in the .vs???\config folder of your solution; and also the .csproj.user folder of your web project. Edit both files and removing the offending configs. Maybe even just delete both files. Then re-open your app in Visual Studio. Good luck!

Solution 23 - Visual Studio

Having just wasted half a day trying to fix this same issue, I felt I should add the solution which eventually worked for me.

TL;DR If netstatindicates that the problematic isn't in use, still try a few others in a totally different range

I've run into this problem before but usually find restarting visual studio, changing ports (increment by 1) or rebooting do the trick. However on this occasion none of this helped, and netstat wasn't finding a conflicting process. I even reinstalled IIS and visual studio and removed several other programs which I suspected could be interfering. It seemed as though IIS was trying to launch multiple instances of the same site.

Eventually I tried running netstat without findstr. I visually scanned the list of active ports and noticed that although the ones I had tried were not listed, there were a few processes using ports in a similar range. So instead I looked for a range which was free, picked a port number and that seems to now be working.

I'd love to hear if anybody can explain why this might have worked?

Solution 24 - Visual Studio

I'm using VS2019 Version 16.10.0 Preview 2.0 and I just went to here:

untick and save anв tick

Unchecked Enable SSL => Save => check it back => Save.

Solution 25 - Visual Studio

I tried the following already:

  • Restarted Visual Studio

  • Check all available ports that might be listening to my specific number but it always return zero results. No processes is listening in my port.

  • I also tried using this but zero results.

    netstat -aon | find ":80"

  • I also tried using but also return zero results.

    netstat -ao | findstr

So what I did is delete this "Microsoft.VsHub.Server.HttpHostx64.exe" then my project successfully started and launch in browser. The error was fixed. I am not sure why but it works.

Here is the screenshot:

enter image description here

Solution 26 - Visual Studio

Installing a component of the IIS seems to be doing the trick

In my case, the easiest solution (and what works constantly) is to try installing a component of the IIS from the Windows 10 (eg. FTP Server). This can be done by going to the Control panel -> Program & features -> Turn Windows features On or Off, and then turning on an IIS component.

Strangely enough, even though the error is related to the IIS Express Web server (and not IIS), installing an extra IIS component, it obviously alters something in the system. After that, the system becomes functional again.

I have tried million things and it didn't seem that the port was somehow reserved by an other app and neither that it maybe was some kind of a firewall problem.

Something that I observed was that this issue was popping up when network related applications were installed or were opened. Examples of these were the update of my Docker Desktop app, installation of VMWare Workstation, Hyper-V activities (like running a VM), etc. I didn't pinpoint the exact reason but I know that somehow these are related.

Solution 27 - Visual Studio

My site worked fine, then started getting this error for no reason. I had many things open (including several VS projects) and didn't want to reboot. I also didn't want to waste time with any of these solutions, so I just changed the port number on the Project URL of the project properties... instant success.

Solution 28 - Visual Studio

The solution is far easier. Just go to the status bar , look for the IIS express icon and stop the site. Solution here: https://stackoverflow.com/a/69841149/8390589

Solution 29 - Visual Studio

As a quick solution, close VS, rename the folder where your website is located and open the website again in VS (File --> Open Web Site...)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPriyaView Question on Stackoverflow
Solution 1 - Visual StudioPhilip TrenwithView Answer on Stackoverflow
Solution 2 - Visual StudioChris SchiffhauerView Answer on Stackoverflow
Solution 3 - Visual StudioYogesh ThoratView Answer on Stackoverflow
Solution 4 - Visual StudioMusicAndCodeView Answer on Stackoverflow
Solution 5 - Visual StudioZotiView Answer on Stackoverflow
Solution 6 - Visual StudioJohn LeonardView Answer on Stackoverflow
Solution 7 - Visual StudioYenneferView Answer on Stackoverflow
Solution 8 - Visual StudioSteve HaselschwerdtView Answer on Stackoverflow
Solution 9 - Visual StudioQamar ZamanView Answer on Stackoverflow
Solution 10 - Visual StudioEmad Gamil AntonView Answer on Stackoverflow
Solution 11 - Visual StudiodjeastmView Answer on Stackoverflow
Solution 12 - Visual StudioAaronKView Answer on Stackoverflow
Solution 13 - Visual StudioChris MoschiniView Answer on Stackoverflow
Solution 14 - Visual StudioÖmer GüngörView Answer on Stackoverflow
Solution 15 - Visual StudioTalha RafiqueView Answer on Stackoverflow
Solution 16 - Visual StudioGary Bao 鲍昱彤View Answer on Stackoverflow
Solution 17 - Visual StudiosingleTrackValeView Answer on Stackoverflow
Solution 18 - Visual Studiobinhtruong.itView Answer on Stackoverflow
Solution 19 - Visual StudioepoxView Answer on Stackoverflow
Solution 20 - Visual StudionPcompView Answer on Stackoverflow
Solution 21 - Visual StudioSiphamandla NgwenyaView Answer on Stackoverflow
Solution 22 - Visual StudioRob KraftView Answer on Stackoverflow
Solution 23 - Visual StudioPhilView Answer on Stackoverflow
Solution 24 - Visual StudioalvipeoView Answer on Stackoverflow
Solution 25 - Visual StudioWilly David JrView Answer on Stackoverflow
Solution 26 - Visual StudioEfthymios KalyviotisView Answer on Stackoverflow
Solution 27 - Visual StudioSpeedRacer350View Answer on Stackoverflow
Solution 28 - Visual StudioJorge ValvertView Answer on Stackoverflow
Solution 29 - Visual StudioGDavoliView Answer on Stackoverflow