Sometimes, after provisioning a new machine, or making some configuration changes, you may find that your IIS server has gone completely missing without so much as leaving you a note.  As you desperately try to bring up your site, your browser connection times out with “server not found” or, slightly better, you get the plain 503 “service unavailable” error.

In these cases, a lot of the instrumentation you typically have at your disposal with application failures is not available to help you fix the problem.  But, not to worry - the solution is usually only a few steps away.  The step-by-step instructions below should help you figure out what’s wrong in minutes.

First, let’s dissect the “server not found” error, which typically looks like this: 

Server Not Found

What is it?

This error means that your browser is unable to establish a connection to the web server at the specified address.

Why does it happen?

The first reason may have nothing to do with IIS - your browser may be unable to resolve the server hostname you specified, or the server is unreachable because of network connectivity or firewall related issues.  If that’s not it, IIS may not be running on the target server, and if it is, your site may be stopped due to configuration issues.

How do I get rid of it?

Lets get rid of it in 3 easy steps:

STEP 1: Make sure your client can resolve the hostname to an ip address and connect to the server. 

Test it can by running the following from command line:

NOTE: Here and below you need to use a command line window running as Administrator in order to execute the commands.  To get an elevated command line window, find it in your start menu, right click, and chose "Run as Administrator"

> ping

If you are unable to resolve the hostname, then your problem is with your client’s proxy server, hosts file, or DNS server.  If you are unable to ping the target server, your problem may be with the client’s network connectivity to the server, or the firewall.

If you can access the server over the network, the second most likely reason is that IIS is not started, or is not listening for requests on the specified hostname/port combination.

STEP 2: Make sure IIS is started.

In order for IIS to accept incoming requests, the W3SVC service needs to be running.  Make sure it is by running the following from command line:

> net start w3svc

If you see the service start, then it was not previously started and you have the answer.  If however you see an error indicating that the service is already started, you may proceed to the next step.

STEP 3: Make sure that your web site is started and is listening to requests

A site has one or more network bindings, each defined by a combination of ip address, port, and hostnames on which the site should receive its requests.  Starting with Windows 2003, IIS uses the http.sys kernel driver to listen for requests, and the W3SVC service to configure it to listen for requests on all binding endpoints associated with your site.  On IIS7, the service doing most of the work is now called WAS (even though W3SVC is till needed).  A configuration error can cause WAS/W3SVC to fail to start a site, and therefore http.sys will not receive requests on its endpoints.  Also, there is the off chance that the site definition itself is missing, or the site does not define the right bindings.

There is a quick way to check whether the site is started, and what end-points its configured to run on, by running the following from command line:

> %windir%system32inetsrvAppCmd.exe list sites

At this point, you may get a configuration error indicating malformed configuration in the sites section – in that case, you need to fix this to proceed.  Once the error has been fixed, the resulting output should include your site as follows:

SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)

If you site is not listed, well, then you know the problem.  If the site definition does not contain the proper binding (in the form of protocol/[ip-address-list-or-*]:port:[host-header-list-or-blank]), then you need to add the missing binding.

If the state shows as Unknown or Stopped, then there is a configuration error that is preventing your site from being started.  Most of the time, the event log holds the key to the exact error. 

Start the event viewer (Start>Run>eventvwr.exe), and look for an error in the “System” event log under “Windows Logs”, with “WAS” as the event source.  You may see something like this:

Event 5161:

Site 1 has no root application defined, so the site will be ignored.

This should most of the time hold the key to what you need to do to make sure the site is valid.  The following may cause your site to not be valid:

  1. The site does not contain a root application (with path = “/”)
  2. The site does not contain a single valid binding
  3. A binding is invalid or conflicts with another binding on the machine

Once you’ve made the required configuration changes, you can start the site like this:

> %windir%system32inetsrvAppCmd.exe start site "Default Web Site"

Where "Default Web Site" is replaced with the name of your site.

At this point, if your client can successfully connect to the server, IIS is started, and your site is started and is listening for requests, you should no longer be timing out with “server not found” errors when connecting to your site.

The next biggest “my server is gone” issue you may hit is the dreaded 503 “service unavailable” error, that looks like this:

Service Unavailable

To deal with this one, check out my other post about troubleshooting "service unavailable" errors.

Bonus: PortChecker tool

I put together a little tool that simplifies the initial check for site’s reachability before you go through the STEP 1 - 3 process to determine the root cause.  This tool tests TCP connectivity to the specific port on the target machine, something that the PING command cannot do.  You can use it to determine whether IIS is listening on a particular ip/port and whether you can get to it – or test connectivity to any arbitrary TCP services (since it will expose DNS, network connectivity, lack of active listening connections), such as SQL Server. 

>> Read more and get PortChecker here <<