• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3619
  • Last Modified:

Custom 503 Error Page IIS? Possible to say something other than service unavailable?

I have been through the list of custom errors in IIS but it does not appear to allow you to specify a custom page for a 503 service unavailable error....is there any way of doing this? Is the default service unaviailble page on disk somewhere or auto-generated?
1 Solution
This may be a start: (Pulled from the IIS help file)

Creating Custom ASP Error Messages
If you develop an application using Internet Server API (ISAPI) or Active Server Pages (ASP) to handle errors, you should customize an error message by mapping to a URL. Note that the error status is handed to the application in the URL parameters, and the application must set the HTTP header status. Otherwise, the HTTP response status is "HTTP 1.1 200 OK."

If you map a custom error message to an ASP file, you must use Server.HTMLEncode to encode your output to avoid cross-site scripting vulnerabilities. Malicious users can send false headers that contain characters like < > " ' % ; ) ( & + - to inject script into the response that is compiled by your ASP custom error file. For example, if you use a header to generate a personal greeting, HTML-encode your output as shown the following example:

<%@ LANGUAGE="VBScript" %>
  Response.CodePage = 1252
  Response.Write("Hello, " & Server.HTMLEncode(Request.Form("UserName")));
  Response.Write("This is why you received an error:");

An alternate solution is to add a function to your ASP custom error file that uses the Regular Expression object of Windows Script Host to remove potentially harmful characters from a string that is sent to the function. The following two ASP examples contain such a function. The first example is written in Microsoft Visual Basic® Scripting Edition (VBScript), and the second example is written in Microsoft JScript®:

<%@ LANGUAGE="VBScript" %>
  Response.CodePage = 1252
  Response.Write("Hello, " & RemoveBadCharacters(Request.Form("UserName")))
  Response.Write("<BR>This is why you received an error:")

  Function RemoveBadCharacters(strTemp)
    Dim regEx
    Set regEx = New RegExp
    regEx.Pattern = "[^\s\w]"
    regEx.Global = True
    RemoveBadCharacters = regEx.Replace(strTemp, "")
  End Function

<%@ LANGUAGE="JScript" %>
  Response.CodePage = 1252;
  Response.Write("Hello, " + RemoveBadCharacters(Request.Form("UserName")));
  Response.Write("<BR>This is why you received an error:");

  function RemoveBadCharacters(strTemp) {
    strTemp = strTemp.replace(/[^\s\w]/g,");
    return strTemp;

In both examples above, the code page is specified to ensure proper encoding.

Related Topics
For information on how to use the 500-100.asp custom error file to process ASP errors, see Enabling ASP Error Processing.


© 1997-2003 Microsoft Corporation. All rights reserved

The problem is how does a server that is unavailable manage to make a response at all?

The initial filters or http.sys must have some default html it spits out when generating th 503 due to not being able to forward the request to the appropriate server process. So where does it get the HTML for the response and can it be modified.

You'll notice in the custom errors tab there is no entry for 503.


jbregAuthor Commented:
Is there an easier way? I don't really want to get into this asp business, just to specify a template--and we do not handle errors in our web application anyway--IIS handles those. I have specified custom errors via IIS Manager but can't find one for 503--where is it? Why is it not there?
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

True but it has to be genereated from somewhere?

I will continue to dig.
jbregAuthor Commented:
Anthony, could not have said it better myself--either that is an autogenerated page or there is a template somewhere. Or maybe there is some other way of specifying the output of 503....
It must be on the local pc that is trying to access the server. I am looking for its location now.
Try this: (Obtained from http://www.web-source.net/custom_error_pages.htm)
Here are some of the more common errors:

400 Bad Request
401 Authorization Required
403 Forbidden
404 File Not Found
405 Method Not Allowed
500 Internal Server Error
501 Method Not Implemented
502 Bad Gateway
503 Service Temporarily Unavailable

Once you've created your pages, you'll need to access your server via FTP and create a new folder called "errordocs" where you store your HTML files. Upload your new error documents into your new folder.

Your next step will be to locate your .htaccess file and download it to your computer. (If you use FrontPage to publish your web pages, you cannot customize the .htaccess file, as FrontPage uses the .htaccess file. Editing the file may cause errors in your configuration.) The .htaccess file should be located on your server where you store your HTML files.

If the .htaccess file isn't visible, you can create one within a plain text editor. However, you must first make sure your server isn't configured to hide the file. Your FTP program should enable you to choose to display hidden files and folders on your server.

Once you've downloaded your .htaccess file, open it within a plain text editor, such as Note Pad, and add the following lines below any other text that may be present:

ErrorDocument 400 /errordocs/400.html
ErrorDocument 401 /errordocs/401.html
ErrorDocument 403 /errordocs/403.html
ErrorDocument 404 /errordocs/404.html
ErrorDocument 405 /errordocs/405.html
ErrorDocument 500 /errordocs/500.html
ErrorDocument 501 /errordocs/501.html
ErrorDocument 502 /errordocs/502.html
ErrorDocument 503 /errordocs/503.html

If you're creating your own .htaccess file, open a plain text editor and add the above lines.

When typing in the information, make certain you type it exactly as it appears above. You can include the error documents of your choice.

Once the file is complete, save it as .htaccess and upload it to your server, via FTP in ASCII mode, where you store your HTML files.
according to Microsoft IIS doco, "The following errors are not customizable: 400, 403.9, 411, 414, 500, 500.11, 500.14, 500.15, 501, 503, and 505."
see: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/80cb8d8d-8fd8-4af5-bb3b-4d11fff3ab9c.mspx
I think http.sys itself is responsible for generating this error.

It is mentioned in the article posted by cjinsocal581 that the instructions are for Unix/Linux server running Apache..
Alimu is dead on.

The 503 error message is *not* customizable.

Dave Dietz
jbregAuthor Commented:

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now