Accessible Error Pages for 404 and 500 Responses
We took an API down for eleven minutes during a database migration last March and served a 503 from the load balancer the whole time. The page was a single centred line of text in a div, no title element, no language attribute, no heading.

We took an API down for eleven minutes during a database migration last March and served a 503 from the load balancer the whole time. The page was a single centred line of text in a div, no title element, no language attribute, no heading. One of our customers uses a screen reader. What he got, three times in a row, was the browser announcing an untitled document followed by silence, because a bare div with no heading and no landmark gives a screen reader nothing to land on.
He sent us a message afterwards that I have kept: I could not tell whether your site was broken or my connection was. That is the actual failure. The outage was planned and short. The error page was the part that turned eleven minutes of downtime into a user who did not know what was happening or when to come back. Error pages get written in the last hour of a project, served from a different box than the application, and tested by nobody, which is why they are quietly the least accessible pages most of us ship.
The status code and the page do different jobs
A screen reader does not announce HTTP status codes. It reads the document. That split catches people out in both directions, so it is worth being precise about who each half is for.
The status code is for machines that are not the browser: crawlers, monitoring, caches, retry logic in client libraries. Returning 200 with a body that says page not found is the classic version of getting this wrong, and single page applications do it constantly because the server has no idea the route failed. The visible result is a search engine indexing your not found page under a dozen URLs. The invisible result is that any client doing automatic retries treats the failure as a success and stops trying.
The document is for the person. It needs a language attribute on the html element so the screen reader picks the right voice, a title element that names both the problem and the site, a level one heading that states what happened in plain words, and a paragraph that says what to do next. None of that comes from the status code. A perfectly correct 404 with an empty body is still a dead end for everyone.
The title element does more work here than anywhere else on a site, because it is the first thing announced and often the only thing read before the user leaves. Page not found followed by the site name beats the default from most frameworks, which is either nothing or the number on its own.
Six things a usable error page has
This is the checklist we now run before an error page ships, and it has survived two years and about forty deploys.
- A language attribute on the html element. Without it a screen reader uses its default voice, and a Dutch sentence read by an English voice is close to unintelligible. This is the single most common omission on pages served by a web server rather than an application.
- A title element with the problem first: not found, then the site name. Browser tabs truncate from the right, and assistive technology reads the start.
- One level one heading that says what happened without the number. Error 500 means nothing to most people. Something went wrong on our side does.
- A real link back into the site, not just a button that calls history.back. On a 404 arrived at from a search result there is no history to go back to, so the button does nothing and the user is stuck. Give the home page and one or two likely destinations.
- For a maintenance page, a time. Even a rough one. Back by about 14:30 UTC is infinitely more useful than we will be back soon, and if you send a Retry-After header to match, well behaved clients stop hammering you.
- Focus placed on the heading when the error is rendered client side. A route that fails inside a single page app replaces the content without moving focus, so the screen reader keeps reading the page the user thought they left. Set focus to the heading and give it tabindex of minus one so it can receive focus without entering the tab order.
The sixth item is the one that catches teams who have done everything else right. Client side error boundaries are a focus management problem, not a markup problem, and they fail the same way a form does when validation messages appear with nothing announcing them.
The funny 404 page deserves pushback
Every list of design inspiration includes a 404 page with an illustration, a joke and an animation. I have shipped two. I now think the genre is mostly a liability, and not for the reason people expect.
The problem is not that humour is wrong. It is that the joke becomes the content. A page whose heading is a pun and whose illustration carries the actual meaning tells a screen reader user nothing, because the illustration either has no alternative text or has alternative text describing a cartoon astronaut. I audited one of mine and the announced content was: lost in space, image, astronaut floating. The word 404 did not appear and neither did the name of the site.
The second problem is the auto redirect. Returning you to the home page in five seconds, with a counter, is a pattern that still ships. It takes control away from somebody who reads slowly, who uses a screen reader, or who was about to copy the URL to report the broken link. Anyone navigating with a keyboard can be moved mid interaction. If you must offer it, make it a link the user chooses.
Animation is the third. A spinning illustration on a maintenance page with no respect for reduced motion preferences is a page you are serving to somebody who may already feel unwell, at the moment they are least able to leave. The media query for this costs three lines.
Keep the illustration if your brand needs it. Mark it as decorative with an empty alt attribute, put the real message in the heading and the paragraph, and make sure the page still reads correctly with images off, which is also how it will reach anybody on a connection bad enough that your assets never arrived.
The pages your application never sees
Here is where infrastructure people like me create the problem. Some error pages are never rendered by your application at all. A 502 from a reverse proxy, a 503 from a load balancer when every backend is unhealthy, a 403 from a CDN edge rule, a 413 when an upload is too large: all of those are generated by software that does not know your stylesheet exists.
The default pages from most web servers are a heading, a horizontal rule and a server signature. No language attribute, no title beyond the status text, no link anywhere. They are also often served without your CSS, because the stylesheet is behind the same unhealthy backend, so anything that depends on an external file degrades to unstyled text.
The fix is unglamorous: write one self contained HTML file per status code you actually serve, with the CSS inline in a style element and no external references at all. Point the proxy at them with the directives it provides, keep each file under about 10 kilobytes, and test them by stopping the backend rather than by opening the file locally. We keep ours in the same repository as the proxy configuration so they get reviewed, and we check them after every change to the edge rules. The related failure mode of dropping requests during a restart is covered in graceful shutdown during deploys.
One more detail that costs nothing: put a skip link on them anyway if the page has any navigation. It is one line and it keeps the pattern consistent with the rest of the site, which matters more than it sounds, and the mechanics are in adding a skip to content link.
FAQ
Should a single page app return a 404 status?
Yes, and it takes server side rendering or a prerender step to do it properly, because the server has to know the route is invalid before it responds. If you cannot, add a robots meta tag with noindex to the rendered error view so crawlers at least stop collecting the URLs.
What should the heading on a 500 page say?
Say that the fault is yours and that the user did nothing wrong, in one short sentence. Then give one action: reload, or come back later, or a status page link. Avoid internal vocabulary. Nobody outside your team knows what an upstream timeout is.
Do I need an aria live region on an error page?
Not for a full page load, where the document is announced from the top anyway. You need one, or a focus move, when the error replaces part of a page the user is already on. Using both at once causes double announcements in several screen readers.
How do I test an error page without breaking production?
Add a route in staging that returns each status on demand and point a browser at it, then run a screen reader over the result with images and CSS disabled. For proxy level pages, stop the backend container in staging and watch what the edge serves. More on this sits in the accessibility section.
More in Accessibility
Accessibility
Accessible Loading States for Slow API Responses
A checkout button on a project I helped with took a median of 900 milliseconds to come back and a p95 of 4.2 seconds, which is...
Accessibility
How to Use the DevTools Accessibility Tree to Debug Names
A ticket landed on my desk years ago that read, in full, "Screen reader says button button on checkout." The developer who...
Accessibility
How to Build Accessible Data Tables for Screen Readers
A sighted user glances at a pricing table and instantly knows that "$29" belongs to the Pro plan and the "Monthly" row.