Unable to connect to web sever IIS Express

0

I am working on project, where I need to have an access to debugging option. I've tried to run my application as usually, but this time I received following message:

Unable to connect to web server 'IIS Express'

When I checked the console output I found there following note:

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

Successfully registered URL "https://localhost:44333/" for site xxx application "/"

I found also that 0x80070020 error - "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" (link to the similar question).

I can't understand what's happen here. When I try to run this application I'm receiving this error in my Visual Studio, but the application is starting in the background (I can manually navigate to the https://localhost:44333 and app is there). The problem is that I can't debug the code, cause the Visual Studio looks like 'unrelated' to this instance. Previously IIS Express was opening new browser window with URL of the application, and I was able to debugging my code.

I also can't understand why this problem is not appearing for brand new project - I've created new web app project to test this behaviour, and it does what I expect - I can use debugging in VS.

What I've tried to do so far is:

  1. Restart VS,
  2. Restart my local machine,
  3. Change app url in solution explorer/properties/debug,
  4. Remove applicationhost.config from .vs directory

and nothing works for me.

Before this issue appear I forked this repo: https://github.com/jasontaylordev/CleanArchitecture and downloaded WSL and Docker - I doubt that this have an impact on my solution, but maybe this information will be helpful.

Is there anything what I can change/edit to back to my previous behaviour?

Thanks

visual-studio
iis-express
asked on Stack Overflow Apr 14, 2021 by Tomitom

1 Answer

0

I had this issue after upgrading to Windows 10 20H2. There are many answers I found on SO that did not work for me, but I found this blog that helped me figure out the problem. Try running netsh interface ipv4 show excludedportrange protocol=tcp on the command liine and check to make sure that the port you are using is not one of the excluded ports listed. If so, change it to one that is not excluded. I did this and everything worked as normal again.

answered on Stack Overflow Apr 14, 2021 by Fred

User contributions licensed under CC BY-SA 3.0