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
- Try switching to port other than 10360 and higher than 1024.
- 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?
i solve the problem this way...
File -> Open -> Web Site...
After that select Local IIS under IIS Express Site remove the unwanted project.
hope this help.
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.
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 -anoat 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
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.
- Close the VS
- Start again - right click and run as admin
- Run your project again.
- Delete the .sln file, if you have one.
- Open the file C:\Users\NN\Documents\IISExpress\config\applicationhost.config
- Locate the problematic site in configuration/system.applicationHost/sites and delete the whole site section.
- "Open Web Site.." from Visual Studio and the project will be given a random new port.
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.
Running visual studio in administrative mode solved my issue
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.
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.
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.
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.
For me netstat did the trick to show me that I had Fiddler running which was keeping the port open.
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
The error message should tell you which application is already using the port - in my case it was explorer.exe, so it was just a case of restarting explorer from task manager.
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)
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
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.
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.
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.
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).
For me, netstat didn't show anything was already using my selected port.
The only thing that worked was deleting the .vs folder in the solution folder.
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.
来源:https://stackoverflow.com/questions/22572897/why-and-how-to-fix-iis-express-the-specified-port-is-in-use

