First Request to IIS Express Fails with 503 Service Unavailable, Second Succeeds

Solution 1:

IIS Express supports Failed Request Tracing and it's turned on by default. The logs are written to %IIS_USER_HOME%\TraceLogFiles which is usually at this location:

%USERPROFILE%\Documents\IISExpress\TraceLogFiles

In that folder you'll see a list of subfolders for each of the projects you've run up in IIS Express. In each site's folder there should be a bunch of frXXXXX.xml files and a freb.xsl file.

Using Firefox or Internet Explorer, open the frXXXXX.xml file(s) that has a time stamp closest to when you get these 503 errors. Once opened you'll see something like the following:

enter image description here

Hopefully you should discover the cause of the 503 error.

You could also try and start IIS Express for your project manually from the command line:

C:\Program Files (x86)\IIS Express>iisexpress /path:"[PATH]" /port:16444

Where [PATH] is the file system path to your project folder containing the site code, web.config etc, for example in your case it would be:

c:\users\chris\dropbox\code\2010\SolutionName\ProjectName

This might throw up some interesting errors if IIS Express can't start the site for the first time.

As an aside you can also tell Visual Studio to "Attach to Process" and start debugging that way.

Solution 2:

The first and foremost action you need to take, is to determine what actually happens.

To do so, turn on Detailed Error Pages for local requests:

appcmd.exe set config -section:system.webServer/httpErrors -errorMode:DetailedLocalOnly /commit:apphost

Now all 400 and 500 class http returns will cause IIS to display a much more detailed error page.