Errors / HTTP errors
502 Bad Gateway
The server you reached works, but the application behind it did not answer properly.
The whole page fails, or, for a request inside a page, whatever it was loading.
Seeing it on someone else’s site?
- It is not your connection or your browser: the site's own servers are failing to talk to each other.
- Reload after a minute; 502s are often a restart or a deploy in progress.
- If it lasts, the site is down for everyone; there is nothing to fix on your side.
Why it happens, if it is your site
- The application behind the web server (Node, PHP-FPM, a container) is down, restarting, or crashed on this request.
- The proxy (nginx, a load balancer, Cloudflare) points at the wrong address or port after a deploy or a config change.
- The application answered something the proxy could not read: headers too large, a connection closed mid-response.
- The application took longer than the proxy allows and was cut off (some proxies say 504 for this, some 502).
How to fix it
- Check the application is running and answering on the port the proxy expects (
curlit from the proxy's machine). - Read the proxy's error log at that minute: nginx says
connect() failed,upstream prematurely closed connectionorupstream sent too big header, and each has its own fix. - Behind Cloudflare, their 502 page says whether the failure is at Cloudflare or at your server.
- If only one request on a page answers 502, it is that endpoint's application, not the whole site.
Whose problem it is
Usually the server that answers the request.
Does your site have it?
Free, no account. We open your page and four more in a clean Chrome and list every error like this one, with the page and the click that caused it. How the free page check works.
Often seen with
- 502 Bad Gateway (nginx)nginx is running, but the application it passes requests to did not answer properly.
- 504 Gateway TimeoutThe server in front waited for the application behind it, and gave up.
- 503 Service UnavailableThe server is up but cannot handle the request right now: overloaded, or in maintenance.
- 500 Internal Server ErrorThe site's server crashed while building the answer.