Origin server
- Typical cause
- The app or web server crashed, restarted, or is not listening where the proxy expects
- Who can fix it
- Site owner or host
A 502 Bad Gateway means a proxy or CDN got an invalid response from the server behind it. See who causes it, how visitors get past it, and how owners fix it.
A 502 Bad Gateway means a server acting as a gateway or proxy, such as nginx, a load balancer or a CDN, received an invalid response from the server behind it. The cause is usually on the site side, not yours. Visitors can retry; owners should check that the origin is running and answering the proxy correctly.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
MDN adds the distinction that matters when you debug. If the origin sends a valid HTTP error response, the gateway should pass that on instead of a 502. If the gateway gets no HTTP response at all within its time limit, it sends a 504 Gateway Timeout. So a 502 points at a reply that was broken, empty or refused, not a slow one.
A 502 does not mean you were blocked. It describes a failure between two servers. A server that understood the request and refuses it sends 403 Forbidden instead, which RFC 9110 defines as "understood the request but refuses to fulfill it".
If the origin was restarting or overloaded, a reload can work. Wait a minute, then try again.
MDN says fixing a 502 probably requires investigation by server owners or administrators, with client networking errors as the exception, particularly if the service works for other visitors and if clients use VPNs or other custom networking setups. Turn off the VPN or try mobile data.
If only your connection fails, check network settings, firewall setup, proxy settings and DNS configuration, as MDN suggests.
If every device and network fails, the owner or host has to fix it. Tell them the time of the error and the exact URL.
proxy_pass or fastcgi_pass line)proxy_buffer_size: the docs say a first response part over the buffer size "is considered invalid"Host headerNonS3OriginDnsError codedig from a public networkcontent-length header as one cause of 502 and 504# From the proxy host, hit the app on its own port
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" http://127.0.0.1:8000/
# Through the public hostname, with response headers
curl -sSI https://example.com/ | head -n 20If your proxy is nginx, the stack-specific checks (socket permissions, buffer sizes, PHP-FPM) are on 502 Bad Gateway in nginx. If the proxy got no HTTP response at all, you will see 504 Gateway Timeout instead.
Causes and fixes differ by server and platform. See the 502 guides for Apache, Cloudflare, nginx.
4 questions people ask next, answered from the sources on this page.
Rarely. A 502 is a gateway or proxy reporting that the server behind it gave an invalid response, so the fix is on the site owner or host side. The exception is your own network: MDN says VPNs, firewall, proxy and DNS settings can cause it when the site works for other people.
A 502 means the gateway received an invalid response from the upstream server. A 504 means the gateway did not receive a response from it in time. In MDN's wording, with a 504 the proxy "did not receive any HTTP response from the origin within a certain time".
Request the origin directly. If it fails, restart or repair the app. If it works, check the proxy or CDN: the upstream address, buffer sizes, TLS settings to the origin, firewall rules and DNS. Then retest through the public hostname.
No. A 502 describes a failure between two servers. A server that understood the request and refuses it responds with 403 Forbidden.
Run the free audit, then approve the fixes. Every change can be undone.