X

IIS Express error: Failed to register URL for site. The process cannot access the file because it is being used by another process.

A little surprise during COVID-19 time coding. I cloned repo to my dev box, opened it in Visual Studio and hit F5. IIS Express starts and browser opens but it shows just error about site to be unreachable. After almost getting grey hair I found out what’s wrong. Here’s the solution.

It wasn’t any of the classic problems. Classic ones have one of these solutions:

  1. Open solution in Windows Explorer, close Visual Studio and delete .vs folder.
  2. Close IIS Express. Go to user folder in Windows Explorer and delete IIS Express subfolder.
  3. Open command prompt, type netstat -aof | findstr :<application port here>

If you have virtualization components enabled like it is in my dev box then make sure your application doesn’t try to use some reserved port.

Open command prompt and run the following command:

netsh interface ipv4 show excludedportrange protocol=tcp

On my dev box I got the following long list of port ranges:

Web application I tried to run was using port 56442 and it fell into one of port exclusion ranges.

Solution

Open properties page of your web application and make it use some available port that is not in port exclusion range.

After changing port click also on Create Virtual Directory button.

Now you are good to go. No need to restart IIS Express or Visual Studio. Just change port, let IIS Express create new virtual directory and run your application.

Liked this post? Empower your friends by sharing it!
Categories: ASP.NET IIS

View Comments (9)

  • Thanks so much, it also solved my problem. Its a pity I found your solution as I'm going to bed, spent well over 3 hours trying to figure out what the issue is. At least tomorrow I can start working again (what's funny though is iv been working on this project on my local machine for days and all of a sudden, the port is now clashing, and I don't recall installing anything else during this period, unless maybe the offending app auto started itself suddenly - Thanks so much for the solution, as well as the solutions to the "Classic Problems".

  • If you use Docker for Windows this can happen regularly. Easiest thing to do is to reserve a list of ports you want to use for ASP.net development and Docker will stop stealing them. If you use Docker for common dependencies during development such as SQL Server on port 1433, MongoDb on 27017, RabbitMq on 5673 and 15672, Seq on 5341, and ElasticSrarch on 9200 and 9300 and finally Kibana on 5601, then I recommend reserving them too.

    > netsh int Add excludedportrange [protocol=]tcp|udp [startport=] [numberofports=] [[store=]active|persistent]

  • Yours is the only solution that worked for me.

    I work for a Fortune 100 company, so we don't have complete control over our network environment, and we're not admins of our own PCs, so our solutions can be limited at times.

    Your insight about the allocated port numbers solved them problem in less than a minute.

  • Great article.
    This solution worked like a charm !! , Thanks for detailing the issue and the solution.
    @Rebeca Thanks for mentioning how my usual port got into excluded range.

  • Doesn't work in my instance. It's odd, my project URL is for https with a specified port number, but the port which it says is already in use isn't even the port number which I have defined.

Related Post