Culture and Reference

502 Bad Gateway error

A server acting as a gateway or proxy (load balancer, CDN, reverse proxy) asked the final server for a response and got something invalid, or none at all.

Common causes

  • The origin server crashed or hung under heavy load.
  • A timeout between the proxy and the application (e.g. PHP-FPM, Node) was reached.
  • A deploy in progress restarted the server mid-request.
  • A misconfiguration in the reverse proxy or CDN.

What to do

  • Wait a minute or two and reload — it is often a passing hiccup.
  • Clear the browser cache and try again.
  • Check whether the site is down for everyone (its official status page, if any).

If you run the server

O que fazer com isso

If you run the server

Check the reverse proxy logs (nginx, Apache) and the application logs for the same time window.

O que fazer com isso

If you run the server

Raise the proxy timeout if the app responds slowly, or optimize the slow query behind it.

Glossário: os termos desta página

HTTP status code

A 3-digit number the server sends with its response, saying whether it worked (2xx), was redirected (3xx), was a visitor-side error (4xx) or a server-side error (5xx).

Ver no glossário completo

Gateway

An intermediate server between the visitor and the final server (reverse proxy, load balancer, CDN). "Bad gateway" errors happen when that intermediary gets no valid response.

Ver no glossário completo

Technology glossary — todos os 11 termos.