65

I have asp.net web application project in visual studio 2012. When I want to start it, I have the following error:

Unable to launch the IIS Express Web server: Port"4012" is in use

This problem came from nothing.How can I resolve it ?

TheChampp
  • 1,337
  • 5
  • 24
  • 41
  • have you tried to change the port number? -->http://stackoverflow.com/questions/2920610/visual-studio-2010-debug-in-a-fixed-port – Edwin Feb 02 '13 at 09:22
  • @Edwin That should work for development server, not for IIS Express. Or has it been changed now in VS2012? – Steve Feb 02 '13 at 09:32
  • Here's another solution: http://stackoverflow.com/questions/4968804/iis-express-web-server-every-port-is-in-use – Edwin Feb 02 '13 at 09:37
  • 1
    It is very strange, yesterday I switched off the computer and all workded fine but today I switched on and this came from nothing. I don't know what to do... – TheChampp Feb 02 '13 at 09:53
  • Do you have your browser open? – Steve Feb 02 '13 at 09:54
  • I tried with closed browser, closed anti-virus program, with no connection to internet and still the same problem. I have 15 projects which worked without problem now all these 15 projects don't want to be opened because of this error. – TheChampp Feb 02 '13 at 09:56
  • Maybe you try to run it two times at the same port. – Aristos Feb 02 '13 at 10:05
  • I restarted the computer 10 times and still nothing. – TheChampp Feb 02 '13 at 10:14
  • Please, look at my answer below and try installing TCPView to find which app keeps your port locked, or simply open a command prompt and type `netstat` – Steve Feb 02 '13 at 11:05
  • Solved after reading http://msdn.microsoft.com/en-us/library/ms178109%28v=VS.100%29.aspx – TheChampp Feb 02 '13 at 13:33
  • My simple fix was to close the open browser and try again. That worked! – DeveloperDan Oct 08 '15 at 12:56

21 Answers21

51

I was having similar problem in visual studio 2012:

ERROR: " Unable to launch IIS Express web server.

Failed to register URL http://localhost:1030/ for site "MySite" application "/". Error Description: The process cannot use file because it is being used by another process. (0x85968574) "

REASON : Actually this port numbers are dynamically generated at runtime. It dosent guranteed to be available. If it is acquires by some other process project wont run. So we need to try at another port.

SOLUTION : There are various solution i found on internet but problem remains unsolved. Finally I tried following solution :

  1. Right click on project in solution Explorer -> Properties
  2. Click on to Web (On LHS).
  3. Look at local IIS Web Server (Which would be radio btn selected by default).
  4. Change port no of project Url e.g : http://localhost:1030/ to http://localhost:45896/ (Possibly Higher than 1024)
  5. Save changes and run application.

This makes changes in IIS config files and wherever needed automatically so we don't need to change any code explicitly. That's work for me hope will work for You too.

Kedar.Aitawdekar
  • 2,364
  • 1
  • 23
  • 25
38

From the MSDN library

Visual Studio cannot guarantee that the port you specify will be available when you run your file-system Web site. If the port is in use when you run a page, Visual Studio displays an error message.

To change the port used by IIS Express to run your program you should follow the procedure outlined by this article on MSDN

How to: Specify a Port for the Development Server

In short, we need to edit the file %systemdrive%:\Users\<username>\Documents\IISExpress\config and change the binding information found in this file and change other configurations for the IIS Express.

As a consequence of this not so simple way to fix the problem, I recommend to close the application that tries to use that port access on you dev computer. Look for specific tools like TCPView from Microsoft that could help to spot the application that grabbed your port. Often it is only the browser

Steve
  • 213,761
  • 22
  • 232
  • 286
  • 2
    Now all work without problems after reading http://msdn.microsoft.com/en-us/library/ms178109%28v=VS.100%29.aspx One last question why this happened from nothing and why I haven't had this problem before. I work with asp.net projects everyday. – – TheChampp Feb 02 '13 at 13:48
  • Have you found which application was using that port? – Steve Feb 02 '13 at 13:59
  • 1
    With TCPView I found two fields with same port and info: "System 4 TCP owner-PC 4012 owner-PC 0 LISTENING " – TheChampp Feb 02 '13 at 14:12
  • Perhaps some services installed/activated recently. – Steve Feb 02 '13 at 14:19
  • Did you have some kind of the same problem ? – TheChampp Feb 02 '13 at 14:20
  • Often, but in my experience it is easy to identify the application responsible, also I usually works with `Visual Studio Integrated Development Server` and changing that port is really easy. Just a property change on the project. – Steve Feb 02 '13 at 14:32
  • 3
    +1 for TCP view! Being able to diagnose the problem properly, rather than just "change the port!", is so refreshing these days! – flipchart Feb 06 '14 at 05:37
  • "Often it is only the browser" - that was it! I closed all browsers and the problem disappeared!!! – andrew.fox Apr 26 '16 at 10:27
  • I found out with TCPView that Spotify was using port 62093. – Frank van Eykelen Mar 28 '19 at 06:56
13

Run "netstat -b" from the command prompt to see what application is using port 4012. If you kill the process IIS Express will be able to launch using port 4012.

dunwan
  • 1,577
  • 2
  • 16
  • 14
  • +1 for the simple command available by default on the command line. In my case it turned out Thunderbird had bound to the local port configured for my development website. – cdlk Dec 18 '13 at 16:46
  • Perfect. It turned out to be the Windows Store. – Todd Skelton Apr 12 '17 at 16:20
9

Killing the IIS Express Worker Process solves this for me; I run into this while trying to debug two concurrent instances of Visual Studio 2015 and switching between the two web solutions.

If this is a constant problem then Kedar's answer of modifying the solution is better, but in a pinch, for a code review, etc I prefer this.

IIS Express Worker Process

Shawn J. Molloy
  • 2,457
  • 5
  • 41
  • 59
6

One solution is to delete or clear the history in your browser. Then, restart the Visual Studio and re-run your application.

If this solution doesn't work, then it's time for you to change the port number for your development server (IIS Express).

I hope it helps you.

Harold Javier
  • 887
  • 2
  • 7
  • 16
2

If this situation is sudden (everything works ok, but suddenly the error Unable to launch the IIS Express Web server is shown) the solution that often works for me is simply:

  • Kill IISExpress process
  • More importantly, close all browsers processes (Firefox, Chrome, Chrome Dev Tools, IE, etc)

Works like a charm :) If doesn't, try different solutions from this thread.

PS. I post it as an answer so it can be found easily, although someone wrote it here somewhere in a comment.

andrew.fox
  • 7,435
  • 5
  • 52
  • 75
2

Try closing Visual Studio and open it again using the "Run as Administrator" option.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40
1

Remove your extra bindings from the config file.

run command prompt as an administrator and type.

1 . netsh http show urlacl

you will see a list of url that has been used, make sure the one you are trying to use currently is listed in this. in the next step you have to delete this reservation.

2 . netsh http delete urlacl url=/Your complete URL as listed in the list above/

after the acknowledgement, restart IIS

Pramod
  • 95
  • 1
  • 10
1

I have also experienced this error when running Fiddler at the same time as Visual Studio. Quitting Fiddler and re-running the application did the trick for me.

Shaun3180
  • 191
  • 2
  • 9
1

Navigate to IIS express

cd "C:\Program Files (x86)\IIS Express\"

run this appcmd.exe list site /xml | appcmd delete site /in

Also, clear your temp files in %temp% and logout, or reboot

This will delete all the sites, enjoy!

Transformer
  • 6,963
  • 2
  • 26
  • 52
0

In my case I had to do two things:

a. Remove the virtual directory from this file:

C:\Users\<user-name>\Documents\IISExpress\config\applicationhost.config

b. run the program TCPView from: http://technet.microsoft.com/en-us/sysinternals/bb897437 Find the process which is using your port, and "End Process".

After this, in Visual Studio, open the web app project properties, select Web tab, click "Create Virtual Directory" button to re-create the virtual directory. Run the web app in debug mode.

scrat.squirrel
  • 3,607
  • 26
  • 31
0

Simply restarting the computer fixed this for me.

cdeutsch
  • 3,847
  • 27
  • 25
0

Try the following steps:

  1. In VS2013 Opened Debug > Website Properties.
  2. Select the "Web" tab.
  3. Under "Servers" I found "Override application root URL" was unchecked. I checked it and saved.
Johnie Karr
  • 2,744
  • 2
  • 35
  • 44
0

Simply go to taskmanager --> Process --> iisexpress --> right click --> end process tree --> then you can build and run your application

Appulus
  • 18,630
  • 11
  • 38
  • 46
kselva
  • 193
  • 2
  • 3
  • 11
0

I had the exact same problem that the OP states "This problem came from nothing."

And I simply just rebooted my machine and it worked again. Restarting IIS Express didn't work.

johntrepreneur
  • 4,514
  • 6
  • 39
  • 52
0

The issue got resolved by following the below steps: - Project-> Properties-> Web - Under Servers select local IIS. - Save the setting and Browse again

0

In web.csproj change the port number

<DevelopmentServerPort>56048</DevelopmentServerPort>
piris
  • 1,547
  • 3
  • 22
  • 26
0

Another option is to delete the applicationhost.config as well from your local solution folder.

Visual Studio stores this as well in a folder called .vs\config in the root of your solution folder.

Delete or edit the applicationhost.config there helped me resolve this

Erik Oppedijk
  • 3,496
  • 4
  • 31
  • 42
0

Please remove your project .vs folder and applicationhost.config file and then run your code.

enter image description here

CDspace
  • 2,639
  • 18
  • 30
  • 36
-1

Much more likely than any of the above answers: delete IISExpress folder, as described in this SO article.

Community
  • 1
  • 1
Andy Brown
  • 5,309
  • 4
  • 34
  • 39
-1

In my case i tried every post I found on net and nothing works, last thing I done is to change option on project right click/ use visual studio web server and all works well now...

Nezir
  • 6,727
  • 12
  • 54
  • 78