prsona
Get started
Critical: fix today

502 Bad Gateway: the server in front of your site got no good answer

Last reviewed

Something between the visitor and your site passed on a bad reply.

A 502 Bad Gateway is the HTTP status returned when a server acting as a go-between, such as a CDN, firewall service or load balancer, receives an invalid response from the server behind it. Your site itself has usually crashed, restarted or refused the connection. The fix starts by checking whether the server behind the gateway is running.

Why a 502 Bad Gateway error costs you customers

Visitors see a plain error page, often branded by your CDN rather than your business, which reads as a site that has been abandoned. A 502 can come and go as the server restarts, so it is easy to miss when you check once and it loads. Google treats repeated 5xx answers as a reason to crawl less and, if they persist, to drop pages.

What usually causes a 502 Bad Gateway error

  • The web server or the app behind it crashed or is restarting
  • Your host is overloaded or the site hit a resource limit on its plan
  • A firewall or CDN cannot reach the server because its address or port changed
  • A recent move to a new host left the CDN pointing at the old server
  • A security rule on the server blocks the CDN's own connections

How to check for a 502 Bad Gateway error yourself

  1. Read the error page closely. If it carries your CDN or firewall service's name, the gateway is fine and the server behind it is the problem.
  2. Reload the page after a minute. A 502 that clears on its own points to a server that restarted; one that stays points to a server that is down or unreachable.
  3. Check your hosting provider's status page and your hosting dashboard for an outage or a "resource limit reached" warning.
  4. If you moved hosts recently, ask whoever manages your CDN which server address it is set to reach.

How to fix a 502 Bad Gateway error

  1. Your host or web person confirms the server and the app behind it are running and restarts them if needed.
  2. If the server is overloaded, your host raises the plan's limits or your web person removes whatever is using up its resources.
  3. Your web person checks the CDN or firewall settings point at the right server address and port, especially after a move.
  4. Your web person allows the CDN's addresses through the server's own firewall if a security rule was blocking them.
  5. Ask your host to alert your web person on crashes and restarts, so a server that keeps falling over gets fixed instead of restarted.

How Prsona catches a 502 Bad Gateway error

Each scheduled scan opens your homepage and the pages linked from it. A bad gateway answer on the homepage is reported as the site being down, naming the code, and on an inner page it is listed as a broken page so your web person can see where it happens.

Prsona looks for a 502 Bad Gateway error as part of uptime monitoring and broken page detection.

Have intermittent errors looked for on each scheduled scan, not just when you remember.

Questions about a 502 Bad Gateway error

Is a 502 error caused by my visitor's internet?

Almost never. A 502 means the gateway in front of your site reached your server and got a bad reply, or no usable reply, so the fault sits between your CDN or proxy and your server, not with the visitor.

Why does a 502 come and go?

Usually because the server behind the gateway is crashing and restarting, or running out of resources at busy times. Each restart briefly fixes it, which is why the cause needs finding rather than another restart.

Sources