HOWTO: Diagnose one cause of 503 Service Unavailable on IIS6

I recently got this question about encountering a 503 Service Unavailable error on 64bit Windows. The author chose to uninstall .NET Framework 1.1 as the resolution, but I think there are some better alternatives...

Question:

I was delighted to run across your treatment of ISAPI Filter 'service unavailable' woes; it gave me the courage to try to get to the bottom of my particular problem. You might (or might not) want to post something of the solution I found in my own situation:

On Windows XP x64 happily running IIS6, the installation of the .NET Framework 1.1 kills the IIS6 with the 'service unavailable' message returned; uninstalling the .NET Framework returned things to the status quo ante.


I am trying to find the blog you wrote on the 503 error and cannot find it. The google link goes to a page that does not have the information on it. I am trying to get Win XP x64 to work with VS 2003 ASP.net 1.1 and I am getting the 503 error and I cannot find any information on what to do about it. Any help would be appreciated.

Answer:

Actually, I think your situation has a better solution than uninstalling .NET Framework 1.1. If my guess is right, you should be able to run .NET Framework 1.1 on 64 bit IIS6.

If you check your Event Log entries, you will likely find several of the following entry, followed by another entry declaring that the Application Pool is being disabled. This disabling is what causes the 503 Service Unavailable to be returned.

 Event Type: Error 
Event Source: W3SVC-WP 
Event Category: None 
Event ID: 2268 

Description: 
Could not load all ISAPI filters for site/service. Therefore startup aborted. 
Data: 0000: c1 00 00 00 

The reason why you are getting this event is straight forward:

  • On 64bit Windows, the "bitness" (i.e. 32bit or 64bit) of a process must match the bitness of the DLLs loaded by that process. In other words, a 64bit EXE can only load 64bit DLLs, and 32bit EXE can only load 32bit DLLs.
  • By default, IIS6 on 64bit Windows runs with 64bit W3WP.EXE worker processes
  • .NET Framework 1.1 has ASP.Net implemented through 32bit ISAPI DLLs.

What is happening when you install .NET Framework 1.1 on IIS6 on 64bit Windows is that while IIS6 runs W3WP.EXE as 64bit, you are configuring it to load some 32bit ISAPI DLLs. This does not work and leads to the event log entry. Since the ISAPI DLLs are loaded for every request, this failure immediately happens again and again, thus triggering the "Rapid Fail Protection" health monitoring check of IIS6. This leads to this Application Pool being taken offline and a 503 Service Unavailable response being sent.

One way to fix this issue is to:

  1. Change IIS6 run W3WP.EXE as 32bit
  2. *** IMPORTANT *** Then restart the Application Pool that returns the 503 error since it is stopped. You cannot fix any 503 error without restarting the Application Pool.

Changing IIS6 to run W3WP.EXE as 32bit allows the 32bit ISAPI DLLs installed by .NET Framework 1.1 for ASP.NET to load and run inside of it. This is done by running the following commandline:

 CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

This command switches IIS6 into running WOW64 (i.e. 32bit compatibility) mode on 64bit Windows on-the-fly so that IIS6 can immediately run 32bit ISAPI DLLs... unless that Application Pool is ALREADY returning 503 errors, in which case you MUST restart the Application Pool to have the bitness switch take effect. It makes sense because a 503 error means the Application Pool is offline and not running, so you must restart it to have setting changes take effect.

You can do this by either:

  • Restarting the Application Pool in question

  • Restarting IIS

     NET STOP W3SVC /y & NET START W3SVC
    
  • Reboot the server

     SHUTDOWN -r -t 0
    

Now, I cannot guarantee that this works for you because you may have other applications that must run as 64bit, in which case you have a conflicting need to simultaneously run 32bit and 64bit code in IIS6, which is not allowed.

See KB 895976 for more details.

I am also going to write up a more complete explanation of WOW64 and running 32bit applications on IIS6 in Windows Server 2003 SP1 (same codebase as Windows XP 64bit Edition) in the near future. I have answered this question to many people for the past year now, and I want to answer it once and for all. :-)

//David