Website Spec
← Resilience
Required

Custom error pages (404, 500)

Custom error pages must return the correct HTTP status code, explain what went wrong in plain language, and offer the user a way forward without leaking implementation details.

What it is

A custom error page is the document a server returns when it cannot fulfil a request. The two pages every site needs are the 404 Not Found for missing resources and the 500 Internal Server Error for unexpected failures. The page must be styled to match the rest of the site and must return the matching HTTP status code in the response headers.

Why it matters

The status code is what crawlers, link checkers, and monitoring tools read. A "page not found" message that returns 200 OK is a soft 404: search engines index the error page, link checkers see no broken links, and analytics tools count failures as normal traffic. Google explicitly treats soft 404s as a quality problem.

For humans, a generic server error page or a stack trace damages trust and may leak file paths, framework versions, or database details that help an attacker. A custom page keeps users in the site and gives them an obvious next step.

How to implement

For a 404:

For a 500:

Configure both pages at the server or edge layer (Nginx error_page, Apache ErrorDocument, Cloudflare custom error pages, Netlify _redirects with status overrides) so they work even when the application is down.

Common mistakes

Verification

Sources