Error pages
6 answers
What visitors see when something goes wrong.
Looking for something specific
The searchable index covers all 326 answers at once and filters as you type.
108 Make my own error pages
- Error Pages, New template.
- Name it, then write a page for each code you care about. 404 and 502 are the two worth doing first.
- Save, then open a site and choose the template.
A template only covers the codes it was ticked for. Anything else falls back to the stock nginx page.
109 Stop my error pages overriding my application
There is a setting per site for whether your templates are also used for errors your application returns. Turn it off and your application's own error pages are passed through untouched.
110 Return JSON errors for an API path
Make a second template that returns a small JSON body, and choose it on the API path rather than on the whole site. A styled apology is no use to a mobile app.
111 What should an error page say?
Keep it short and say what the visitor should do. A page that says the site is having a problem and to try again in a few minutes is worth more than a clever design.
Leave the technical detail out. It does not help the visitor and it tells anybody probing your site more than they need to know. Inline any styling, because a stylesheet on the backend that just went down will not load.
199 Show my error pages when the backend is the one that failed
Open the site, Settings tab, tick Show advanced settings, then Proxy, and tick Use my error pages for backend errors.
Without it, a 500 from your application goes to the visitor exactly as written, which on a bad day is a stack trace with file paths and sometimes a database name in it.
Turn it off again for API paths, where the caller wants the real error body.
200 Put a picture on an error page
Error Pages, open the template, and use the Pictures section. The image is stored with the template and copied to every node, so it works when the backend is down. That is the whole point, and it is why linking to an image on your own site does not work here.
Keep it small. An error page that takes three seconds to load is worse than a plain one.