Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using nginx as reverse proxy for a single machine. I would like to have an error page when the backend machine goes down.

This is my configuration file:

server {
    listen   80;
    access_log  /var/log/nginx/access.log;
    root /var/www/nginx;
    error_page 403 404 500 502 503 504 /error.html;
    location / {
            include         /etc/nginx/proxy.conf;
share|improve this question
You already do. What is the problem? – Michael Hampton Sep 11 '12 at 14:01
I receive a 502 "Bad gateway" instead that error.html – Lormayna Sep 11 '12 at 14:17
This is an error: 2012/09/11 16:32:10 [error] 5544#0: *7 connect() failed (110: Connection timed out) while connecting to upstream, client:, server: hansolo, request: "GET /error.html HTTP/1.1", upstream: "";, host: "" – Lormayna Sep 11 '12 at 14:31

Aha, I see the problem. You have provided no way for nginx to actually serve static files such as /error.html, so it is trying to pass them upstream to your backend.

The quick fix would be:

location /error.html {

This will cause nginx to handle /error.html itself. It will then try to serve the file out of the defined document root.

By the way, you probably want to use different error pages for 4xx errors and 5xx errors. "Not found" or whatever is not what you want people (or search engines!) to see if a backend is down temporarily.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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