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.exeprocess 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:
- Press
Ctrl + Shift + Escto open Task Manager. - Navigate to the Processes tab.
- Scroll down or search for
iisexpress.exe. - 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.
- Open an elevated command prompt (right-click Command Prompt and select Run as administrator).
- Run the
netstatutility 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
- Expand your project in the Solution Explorer.
- Open the
Propertiesfolder and double-clicklaunchSettings.json. - Locate the
applicationUrlproperty under your profile (for example,http://localhost:5000;https://localhost:5001). - Modify the port numbers to a clean, unreserved range (such as
5050or8080). - Save the file and restart your project.
For Traditional ASP.NET / .NET Framework Projects
- Right-click your web project in Solution Explorer and select Properties.
- Click on the Web tab in the left-hand menu.
- Under the Servers section, look at the Project Url field.
- Change the port number to a new value (for instance, changing
http://localhost:12345/tohttp://localhost:13333/). - 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.
- Close Visual Studio completely.
- Navigate to your solution folder on your disk and delete the hidden
.vsfolder, as well as the localbinandobjdirectories. - If the problem persists at the machine level, navigate to your user profile directory:
C:\Users\YourUsername\Documents\IISExpress\config. - Open
applicationhost.configin a text editor like Notepad. - Locate the `