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

73

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
iis-express
asked on Stack Overflow Mar 18, 2015 by Priya • edited Jun 4, 2019 by Lucas

17 Answers

106

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.

answered on Stack Overflow Jan 27, 2016 by Chris Schiffhauer • edited Nov 3, 2017 by Chris Schiffhauer
26

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

answered on Stack Overflow Mar 3, 2016 by MusicAndCode
20

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)
answered on Stack Overflow Jul 5, 2017 by Zoti
11

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.

answered on Stack Overflow Oct 21, 2016 by Steve Haselschwerdt • edited Oct 26, 2017 by Steve Haselschwerdt
3

Another application is using that port. This could help you

answered on Stack Overflow May 13, 2015 by Kautsky Lozano
2

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.

answered on Stack Overflow May 31, 2016 by Chris Moschini • edited May 23, 2017 by Community
2

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.

answered on Stack Overflow Jan 11, 2017 by singleTrackVale
2

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.

answered on Stack Overflow Jul 23, 2018 by epox
2

In my case, doing the following did the trick:

  • Delete the Site from .vs\\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

answered on Stack Overflow Jun 12, 2019 by djeastm
1

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

answered on Stack Overflow Jul 16, 2018 by binhtruong.it
1

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>
answered on Stack Overflow Oct 26, 2018 by nPcomp • edited Oct 26, 2018 by nPcomp
1

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?

answered on Stack Overflow Apr 4, 2019 by Phil
1

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
answered on Stack Overflow Apr 10, 2019 by AaronK
1

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.

1

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!

answered on Stack Overflow Oct 28, 2019 by Rob Kraft
1
  1. Close visual studio
  2. delete ".vs" folder
  3. Try change port "localhost:8080"

It worked for me.

answered on Stack Overflow Nov 9, 2019 by Ömer Güngör
0

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

answered on Stack Overflow Feb 22, 2018 by Willy David Jr

User contributions licensed under CC BY-SA 3.0