software

Fix Iis Express Port Already In Use Error Quickly

When you hit the IIS Express port already in use error in Visual Studio, your local debugging session grinds to a halt. You click debug, expect your browser to spin up with your local application, and

Fix Iis Express Port Already In Use Error Quickly
In this story

When you hit the IIS Express port already in use error in Visual Studio, your local debugging session grinds to a halt. You click debug, expect your browser to spin up with your local application, and instead get greeted by a stubborn error message stating that the specified port is already occupied. This happens because another process—often a rogue background instance of IIS Express, a previous build of your own app, or Windows features like Hyper-V—has already claimed your designated TCP port.

Fixing this isn't difficult once you know where to look. Let's walk through how to identify the conflicting process, change your project configuration, or resolve Windows port reservation issues so you can get back to coding.

Why the IIS Express Port Conflict Happens

IIS Express relies on specific TCP/IP ports to serve your local web applications. When Visual Studio launches a web project, it requests a binding for a specific port number (such as 5000, 10360, or 44300). If that port is unavailable, initialization fails immediately.

Several common culprits trigger this issue:

  • Orphaned Processes: A previous debugging session didn't terminate cleanly, leaving an iisexpress.exe process running silently in the background.
  • Port Reservation Ranges: Windows features like Hyper-V, Docker Desktop, or Windows NAT (winnat) occasionally reserve dynamic port ranges that overlap with your development ports.
  • Project File Settings: Visual Studio solutions containing multiple web projects can accidentally assign duplicate port numbers across different projects.

Method 1: Terminate Rogue IIS Express Instances

Most of the time, the port is locked by a zombie instance of your own web server. You can clear these out using Task Manager or the command line.

Open your command prompt or PowerShell window and run this command to force-stop all running instances of IIS Express:

iisexpress /stop

Alternatively, use Task Manager:

  1. Press Ctrl + Shift + Esc to open Task Manager.
  2. Navigate to the Processes tab.
  3. Scroll down or search for iisexpress.exe.
  4. Right-click the process and select End Task.

If multiple background instances were lingering, closing them frees up your designated port instantly. Restart Visual Studio and try launching your debugging session again.

Method 2: Identify the Process Using Your Port

If ending IIS Express tasks doesn't work, another application or Windows service is squatting on your port. You need to find out which executable owns it.

  1. Open an elevated command prompt (right-click Command Prompt and select Run as administrator).
  2. Run the netstat utility with flags to show active connections, numerical addresses, and the owning process ID:
netstat -aob

Scroll through the list or use findstr to search for your specific port number (for example, netstat -aob | findstr 5000). Look for the line indicating LISTENING and note the executable name and PID listed right below it.

Once you have the PID, open Task Manager, switch to the Details tab, find that PID, and end the task. If the port is held by a core system service like winnat (common when Docker or Hyper-V is running), you'll need to handle dynamic port exclusions.

Method 3: Change Your Project Port in Visual Studio

If the assigned port is permanently blocked by a system service or another active application you can't kill, change your project's port configuration.

For ASP.NET Core Projects

  1. Expand your project in the Solution Explorer.
  2. Open the Properties folder and double-click launchSettings.json.
  3. Locate the applicationUrl property under your profile (for example, http://localhost:5000;https://localhost:5001).
  4. Modify the port numbers to a clean, unreserved range (such as 5050 or 8080).
  5. Save the file and restart your project.

For Traditional ASP.NET / .NET Framework Projects

  1. Right-click your web project in Solution Explorer and select Properties.
  2. Click on the Web tab in the left-hand menu.
  3. Under the Servers section, look at the Project Url field.
  4. Change the port number to a new value (for instance, changing http://localhost:12345/ to http://localhost:13333/).
  5. Click Create Virtual Directory if prompted, save your changes, and rebuild your solution.

Method 4: Clear Visual Studio Caches and Config Files

Sometimes Visual Studio caches stale bindings in local configuration files or hidden directories. Clearing these forces the IDE to regenerate a clean working environment.

  1. Close Visual Studio completely.
  2. Navigate to your solution folder on your disk and delete the hidden .vs folder, as well as the local bin and obj directories.
  3. If the problem persists at the machine level, navigate to your user profile directory: C:\Users\YourUsername\Documents\IISExpress\config.
  4. Open applicationhost.config in a text editor like Notepad.
  5. Locate the `
SB

Written by

Samuel Baker

Samuel Baker approaches each story with intellectual curiosity and a commitment to fairness, earning the trust of readers and sources alike.

More from software