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

这一生的挚爱 提交于 2019-11-26 13:09:56

问题


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?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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




回答5:


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.




回答6:


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



回答7:


  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.



回答8:


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.




回答9:


Running visual studio in administrative mode solved my issue




回答10:


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.




回答11:


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.




回答12:


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.




回答13:


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




回答14:


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.




回答15:


For me netstat did the trick to show me that I had Fiddler running which was keeping the port open.




回答16:


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




回答17:


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.




回答18:


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)




回答19:


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




回答20:


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.




回答21:


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




回答22:


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.




回答23:


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).




回答24:


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.




回答25:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!