Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 259
Blaise Avatar asked Mar 22 '14 03:03

Blaise


People also ask

How do I resolve a port already in use?

If you are running the Development Application Server, changing the port used by the server is the easiest solution. Change the Server Port in the Application Server Control Panel and start the server. Specify a port that is not 80, such as 8080. Changing the port number may not desired in a Production environment.

How do I change the port on IIS Express?

In Solution Explorer, right-click the name of the application and then select Properties. Click the Web tab. In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number. To the right of the Project URL box, click Create Virtual Directory, and then click OK.

Which port does IIS Express use?

By default, you can use IIS Express to run your website using a non-reserved port such as 8080. However, using a reserved port such as 80 or 443 requires work. The steps described below assume you want to support local traffic over port 80.


2 Answers

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.

like image 81
Philip Trenwith Avatar answered Sep 23 '22 00:09

Philip Trenwith


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.

like image 32
yean Avatar answered Sep 21 '22 00:09

yean