So I have a very basic site that's hosted in IIS (for now just straight raw html with no .Net code)

In my web.config I have the following:

<?xml version="1.0" encoding="UTF-8"?>
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />

This was added into the web.config by the IIS manager - and it reflects what I've found online as the valid configuration for 404 errors to redirect to my custom 404 page.

However I still get the IIS generated HTTP Error 404.0 - Not Found page back whenever I go to a page that doesn't exist.

Any ideas what I'm doing wrong here?


  • IIS 10/IIS 8.5 (Tested on both)
  • Windows 10/Windows 8.1 (Tested on both)
  • DefaultAppPool
  • Chrome, Edge, Internet Explorer, Firefox (All latest)
  • 2
    Are you requesting the resource on localhost? If so it might be because the errorMode defaults to DetailedLocalOnly. Try <httpErrors errorMode="Custom"> – Mathias R. Jessen Jul 29 '15 at 0:55
  • Bam! That did it - I didn't even think about the fact that I was hitting it from localhost. Post as an answer and I'll mark it for you as such – Robert Petz Jul 29 '15 at 2:47

Whenever a configuration element in my IIS config files doesn't produce the behavior I expect, the first place I look is always the official (and quite comprehensive) IIS.net Configuration Reference documentation.

If you browse to the httpErrors page and scroll down to "Attributes", you'll find that the errorMode attribute defaults to a value of "DetailedLocalOnly", and what that implies:

Returns detailed error information if the request is from the local computer, and returns a custom error message if the request is from an external computer.

Aha! If your request results in an error page while browsing locally, you get a detailed error page rather than your custom one!

Just below, there's an entry for a Custom value:

Replaces the error that the module or server generates with a custom page that you specify. This mode is useful in providing friendlier error messages to end users.

Note: This setting turns off detailed errors, even for local requests.

And that's it, just add the attribute errorMode with a value of Custom to the httpErrors node to override the default:

<httpErrors errorMode="Custom">
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.