Why and how to fix? IIS Express "The specified port is in use"

Visual Studio-2013Iis Express

Visual Studio-2013 Problem Overview


We know a random port number is assigned to a web application in Visual Studio. It works fine in my office desktop. But when I pull the code onto my laptop (from VisualStudio.com) and run the web app. I got a message, saying,

The specified port is in use

Port 10360 is already being used by another application.

Recommendations

  1. Try switching to port other than 10360 and higher than 1024.
  2. Stop the application that is using port 10360.

I can fix it using Recommendation #1 by changing the port into something else like 13333. But I am very curious what happened to port 10360. How can I check what application is using port 10360? How can I stop that application?

Visual Studio-2013 Solutions


Solution 1 - Visual Studio-2013

I had a similar issue running Visual Studio 2019 on Windows 10. Some solutions that worked for others seemed to include:

  1. Changing the application port number.
  2. Have Visual studio automatically assign a port number each time the application start.
  3. Restart Visual Studio
  4. Restart the computer.

Unfortunately, none of these solutions worked for me, assigning another port number did work but was not an acceptable solution as it was important for my application to run on a specified port.

The Solution

First I ran the command:

netsh http add iplisten ipaddress=::

from an elevated command-line process. This solved the initial error, when attempting to run the application I no longer got the "port in use" error, instead, I now got an error stating the application was unable to bind to the port because administrative privileges were required. (although I was running Visual Studio as administrator)

The second error was caused by Hyper-V that adds ports to the Port Exclusion Range, the port my application uses was in one of these exclusion ranges. You can view these ports by running the following command: netsh interface ipv4 show excludedportrange protocol=tcp

To solve this second error:

  1. Disable Hyper-V: Control Panel-> Programs and Features-> Turn Windows features on or off. Untick Hyper-V
  2. Restart the computer.
  3. Add the port you are using to the port exclusion range: netsh int ipv4 add excludedportrange protocol=tcp startport=50403 numberofports=1 store=persistent
  4. Reenable Hyper-V
  5. Restart the computer

From here everything worked perfectly.

Solution 2 - Visual Studio-2013

i solve the problem this way...

File -> Open -> Web Site... enter image description here

After that select Local IIS under IIS Express Site remove the unwanted project.

hope this help.

Solution 3 - Visual Studio-2013

  1. change it in solution (right Click) -> property -> web tab
  2. Click Create Virtual Directory (in front of project Url textbox)

IIS Express port change for fixing port in use

Solution 4 - Visual Studio-2013

This was haunting me for over a year!

For me,

  • no website was running iin IIS Express
  • nothing was using the port as determined by running: netstat -ano at the command line.

The solution was to run

netsh http add iplisten ipaddress=::

from the command line.

Happy days, and credit to: James Bryant! https://developercommunity.visualstudio.com/content/problem/110767/specified-port-is-in-use.html

Solution 5 - Visual Studio-2013

I had the same problem, but no proccess appeared neither in netstat nor in resmon.

What solved the problem for me was closing all the open browser windows.

Solution 6 - Visual Studio-2013

SIMPLE SOLUTION THAT WORKED FOR ME: (Credits to combination of other's answers)

**My System Info:**
Windows 10 build : 1809
IIS Version      : 10.0.17763.1
Hyper-V          : Enabled
Docker           : Installed - 2.3.0.2 (45183)
  • Check for blocked ports range in CMD (admin)

    >> netsh interface ipv4 show excludedportrange protocol=tcp
    
    (Sample output):
    Protocol tcp Port Exclusion Ranges
    Start Port    End Port
    ----------    --------
    49696       49795         (SEE HERE, 49796 to 49895 is not blocked)
    49896       49995
    ... list goes on ...
    
  • Open Visual Studio and Navigate to > Project > Properties > Web > Servers > Project Url

  • Use the Port that is not blocked.

    (Sample port):
    http://localhost:49796/
    
  • Restart Visual Studio (if required)

  • Have a coffee and share love. (required) :)

Solution 7 - Visual Studio-2013

You're looking for netstat.

Open an administrative command shell and run

netstat -aob

And look for port 10360. It'll show you what executable opened the port and what PID to look up in Task Manager. (Actually, run netstat -? in an unprivileged shell first, because I don't approve of blindly running anything you don't understand, especially in a privileged context.)

Here's what the switches do:

-a shows all connections or open ports, not just active ones - the port you want is probably listening, not active.

-o shows the owning PID of the connection or port, so you can find the process in Task Manager's Processes tab. (You might need to add the PID column in Task Manager. View->Select Columns)

-b shows the binary involved in opening the connection or port. This is the one that requires elevated access.

Solution 8 - Visual Studio-2013

  1. Close the VS
  2. Start again - right click and run as admin
  3. Run your project again.

Solution 9 - Visual Studio-2013

The cause of this issue in my own case is a bit different. Everything was working fine until I started docker to do some other stuff. Starting docker, in one way or the other, added some new ranges of ports to the Port Exclusion Ranges. What to do:

  1. Open command prompt (As an administrator)
  2. run: netsh interface ipv4 show excludedportrange protocol=tcp (You should see the port your application is using in the excluded port ranges)
  3. run: net stop winnat
  4. run: netsh interface ipv4 show excludedportrange protocol=tcp (by this time, the Administered port exclusions ranges should reduce)
  5. run net start winnat.

If the problem was caused by Windows NAT Driver (winnat), then you should be good by now.

Solution 10 - Visual Studio-2013

Running visual studio in administrative mode solved my issue

Solution 11 - Visual Studio-2013

For me the "The specified port is in use" error is usually fixed (well actually worked arround) by stopping the "Internet Connection Sharing (ICS)" (SharedAccess) and the "World Wide Web Publishing Service" (W3SVC) service.

After the project / ISS Express is started the stopped services can be started again without issues.

Whenever i receive the error the port (in the 50000 range) is definitely not in use (checked with netstat & tcpview).

It would be nice if Microsoft did some integration testing of Visual Studio / IIS Express along side with HyperV and the "normal" IIS Service OR gave some guidance on which port ranges to use for VS / IIS Express (and which ports to avoid).

Solution 12 - Visual Studio-2013

  1. Delete the .sln file, if you have one.
  2. Open the file C:\Users\NN\Documents\IISExpress\config\applicationhost.config
  3. Locate the problematic site in configuration/system.applicationHost/sites and delete the whole site section.
  4. "Open Web Site.." from Visual Studio and the project will be given a random new port.

Solution 13 - Visual Studio-2013

If netstat doesn't show anything, try a reboot.

For me, nothing appeared in netstat for my port. I tried closing Google Chrome browser windows as @Clangon and @J.T. Taylor suggested, but to no avail.

In the end a system reboot worked, however, so I can only assume that something else was secretly holding the port open. Or perhaps it just took longer than I was prepared to wait for the ports to be released after Chrome shut down.

Solution 14 - Visual Studio-2013

For me, close all application and restart the computer.

When window start, Open Visual studio first, then open browser and click run(F5).

Now it works. I don't know why.

Solution 15 - Visual Studio-2013

Visual studio 2015

  • Close all the files you have open inside Visual studio.
  • Then close application and exit Visual Studio.
  • Open Visual Studio and it should successfully run.

I hope this helps.

Solution 16 - Visual Studio-2013

Open Task Manager and Just Close all processes of 'IIS Express System Tray' and 'IIS Express Worker Process' and Re-run the Project

Task Manager Process Details

Solution 17 - Visual Studio-2013

netstat didn't show anything already using the port

netstat -ano | findstr <your port number> showed nothing for me. I found out that port was excluded using this command to see what ranges are reserved 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>

However, in my case I couldn't unblock the range, I just got "Access is denied", so I ended up having to pick another port for my site.

My original solution: The only thing that worked was deleting the .vs folder in the solution folder. (I've since found you can just delete the .vs/config/applicationhost.config instead to avoid losing so many settings).

Solution 18 - Visual Studio-2013

For me, the Google Chrome browser was the process which was using the port. Even after I closed Chrome, I found that the process still persisted (I allow Chrome to "run in background" so that I can receive desktop notifications). I went into Task Manager, and killed the Chrome browser process, and then started my web application, it worked like a charm.

Solution 19 - Visual Studio-2013

Open your csproj with for example Notepad ++ and scroll down to DevelopmentServerPort. Change it to something else as long as it's above 1024 like rekommended (so for example 22312). Also change the IISUrl to http://localhost:22312/. Save your changes and restart the project.

Solution 20 - Visual Studio-2013

In my case there was no application using specified port and elevated running of Visual Studio didn't help either.

What worked for me is to reinstall IIS Express and than restart computer.

Solution 21 - Visual Studio-2013

For me it was an orphaned VBCSCompiler task from a previous run, that didn't shut down and was somehow interfering. Killing that task solved it.

https://developercommunity.visualstudio.com/content/problem/31482/vbcscompiler-does-not-shut-down.html

Solution 22 - Visual Studio-2013

You need to configre this parameter by running the following in the administrative command prompt:

> netsh http add iplisten ipaddress=::

Solution 23 - Visual Studio-2013

click on the notification present on bottom of the task bar if you receiving the error like port in use then select the iiss icon right click then click on exit ,it work like charm for me

Solution 24 - Visual Studio-2013

I had same error showing up. I had my web service set as an application in IIS and I fixed it by:

Right-click on my WebService project inside my solution > Properties > Web > Under 'Servers' change from IIS Express to Local IIS (it will automatically create a Virtual Directory which is what you want)

Solution 25 - Visual Studio-2013

When Port xxxx is already being used, there's always a PID (Process Id) elaborated with the error. Simply go to the task manager on the machine you are running the application, click on details, and you will identify what the other application is. You can then decide whether you want to end that process or not

Solution 26 - Visual Studio-2013

Just to add to this, I had the full IIS feature turned on for one of my machines and it seemed to cause this to happen intermittently.

I also got random complaints about needing Admin rights to bind sites after a while, I assume that somehow it was looking at the full IIS config (Which does require admin as it's not a per-user file).

If you are stuck and nothing else is helping (and you don't want to just choose another port) then check you have removed this if it is present.

Solution 27 - Visual Studio-2013

FWIW, I tried tons of these options and I didn't get anywhere. Then I realized I had installed VMWare Player just before the issue started. I uninstalled it, and this error went away.

I'm sure there's some way to make them coexist, but I don't really need Player so I just removed it. If you've tried all kinds of stuff and it's not working consider looking through any programs you've installed recently (especially those that deal with network adapters?) and see if that gets you anywhere.

Solution 28 - Visual Studio-2013

In Visual Studio 2017, select Project/Properties and then select the Web option. In the IIS section next to the default project URL click Create Virtual Directory. This solved the problem for me. I think in my case the default project Virtual Directory had been corrupted in some way following a debugging session.

Solution 29 - Visual Studio-2013

For me only thing worked is removing the element containing my application name, path and binding info under element in applicationhost file. To be found under C:\Users\yourUsername\Documents\IISExpress\config

Closed the the solution , deleted the bad site element , save the applicationhost file and close. Reopen the application/Website from Visual studio using Admin rights - Rebuilt and Run. Voila... A new port is auto assigned to your application which solves the purpose.

Can also be verified without running-- check the Properties window for the solution and URL will have new port number.

Solution 30 - Visual Studio-2013

In my case I got also this issue from my ASP Core 3.1 projets. I thing that for some reason visual studio ignore the IP/Port setting in the project property and start it on 5000 and 5001. I discovered this while attempting to start my Core 3.1 projects from prompt using dotnet run

And this post helped me https://stackoverflow.com/questions/37365277/how-to-specify-the-port-an-asp-net-core-application-is-hosted-on

It suggest to

  • Specify the port in the appsettings.json or maybe appsettings.development.json. (see lower)
  • Close Visual Studio
  • Delete /.vs, /bin, /obj folders
  • Restart Visual Studio.

appsettings.json / appsettings.development.json content

 {   
      /***************************
      "Urls": "http://localhost:49438", <==== HERE
      /***************************/
      
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "AllowedHosts": "*",
      "connectionStrings": { ...  }
    } 

Solution 31 - Visual Studio-2013

To Solve this issue follow the below step:

  1. Open the CMD run as Administrator mode

  2. Then execute the command netsh http add iplisten ipaddress=::

  3. After run the project

Solution 32 - Visual Studio-2013

Just do these,

  1. stop the running project
  2. close the browser(s)
  3. run the project

Solution 33 - Visual Studio-2013

The same error was appearing in my Visual Studio 2021. After installing Docker every port was engaged by Kubernetes.WDS.

Simple 2-step solution:

  1. Disable Hyper-V: Control Panel -> Programs and Features -> Turn Windows features on or off. Untick Hyper-V.
  2. Restart the computer.

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
QuestionBlaiseView Question on Stackoverflow
Solution 1 - Visual Studio-2013Philip TrenwithView Answer on Stackoverflow
Solution 2 - Visual Studio-2013yeanView Answer on Stackoverflow
Solution 3 - Visual Studio-2013ImanView Answer on Stackoverflow
Solution 4 - Visual Studio-2013Liam FlemingView Answer on Stackoverflow
Solution 5 - Visual Studio-2013ClangonView Answer on Stackoverflow
Solution 6 - Visual Studio-2013Naveen Kumar VView Answer on Stackoverflow
Solution 7 - Visual Studio-2013user3448731View Answer on Stackoverflow
Solution 8 - Visual Studio-2013MansiView Answer on Stackoverflow
Solution 9 - Visual Studio-2013abibtjView Answer on Stackoverflow
Solution 10 - Visual Studio-2013Mujtaba ZaidiView Answer on Stackoverflow
Solution 11 - Visual Studio-2013MichelView Answer on Stackoverflow
Solution 12 - Visual Studio-2013Jonas ÄppelgranView Answer on Stackoverflow
Solution 13 - Visual Studio-2013Paul StephensonView Answer on Stackoverflow
Solution 14 - Visual Studio-2013OammieRView Answer on Stackoverflow
Solution 15 - Visual Studio-2013saurav singhView Answer on Stackoverflow
Solution 16 - Visual Studio-2013SumairIrshadView Answer on Stackoverflow
Solution 17 - Visual Studio-2013John LeonardView Answer on Stackoverflow
Solution 18 - Visual Studio-2013J.T. TaylorView Answer on Stackoverflow
Solution 19 - Visual Studio-2013K.OleksiakView Answer on Stackoverflow
Solution 20 - Visual Studio-2013MirhatView Answer on Stackoverflow
Solution 21 - Visual Studio-2013Thread PittView Answer on Stackoverflow
Solution 22 - Visual Studio-2013Md. Rizwanul IslamView Answer on Stackoverflow
Solution 23 - Visual Studio-2013ashish VickyView Answer on Stackoverflow
Solution 24 - Visual Studio-2013Cristian GView Answer on Stackoverflow
Solution 25 - Visual Studio-2013Ken.FukiziView Answer on Stackoverflow
Solution 26 - Visual Studio-2013Dan HarrisView Answer on Stackoverflow
Solution 27 - Visual Studio-2013trademarkView Answer on Stackoverflow
Solution 28 - Visual Studio-2013user3615720View Answer on Stackoverflow
Solution 29 - Visual Studio-2013Bibha GauravView Answer on Stackoverflow
Solution 30 - Visual Studio-2013HugoView Answer on Stackoverflow
Solution 31 - Visual Studio-2013Sumant SinghView Answer on Stackoverflow
Solution 32 - Visual Studio-2013saimum720View Answer on Stackoverflow
Solution 33 - Visual Studio-2013Rayhan XafarView Answer on Stackoverflow