Error 502: Bad Gateway
Is the proxy not getting an answer from your server? Check right here whether the 502 persists or was just a blip.
Checks the status code, every redirect, the variants with and without www and over http and https, the SSL certificate and the response time.
Free, no sign-up - no data about you is stored.
Result
Technical finding without guarantee. The check runs once from a server in Germany. If your website is only unreachable from certain networks or countries, the result may differ.
What does Error 502 mean?
A 502 Bad Gateway happens when two servers work together: a server in front, such as nginx, a load balancer or a CDN like Cloudflare, accepts the request and passes it on to the actual server. If it gets no response or an unusable one, the server in front reports 502.
The best-known version is the plain "502 Bad Gateway" page with "nginx" underneath. It doesn't mean nginx is broken, but that nginx can't reach PHP or the application server behind it. The fault is always on the server side.
Common causes.
PHP-FPM isn't running or has crashed
nginx hands PHP requests to PHP-FPM. If the service is stopped, has crashed or wasn't restarted after an update, you get a 502.
Wrong connection to PHP
After switching PHP versions, the config still points to the old socket or port where nothing answers anymore.
PHP process dies
A plugin crashes PHP, or the process is killed for using too much memory. The connection drops before a response arrives.
Response headers too large
If the application sets lots of cookies, the headers exceed the proxy buffer. nginx then logs "upstream sent too big header".
Server behind the CDN unreachable
With Cloudflare or a reverse proxy, the actual server is down, overloaded or blocks the proxy with a firewall.
With WordPress and hosting.
With WordPress on nginx and PHP-FPM, a 502 usually comes from PHP: the service didn't start cleanly after a PHP update, a plugin crashes PHP, or all PHP workers are busy and new requests are turned away. With Plesk and similar panels, nginx often runs in front of Apache, and there too 502 means the server behind it isn't answering.
In WooCommerce shops with lots of cookies, the 502 sometimes only shows up on certain actions, like the cart or login, because the response headers get too large. With Cloudflare, an error page in Cloudflare's design shows whether the 502 comes from Cloudflare or from your own server. If it points to your server, the problem lies with your hosting.
How to fix it.
Reload after a moment
A single 502 after a restart or update often disappears within seconds. Run the checker above a few times to see whether it sticks.
Restart PHP
Many hosting panels let you restart PHP or PHP-FPM, or simply re-save the PHP version. On your own server, restart the service.
Read the web server's error log
The nginx or proxy log names the exact reason, such as "connection refused", "no such file" for the socket, or "upstream sent too big header".
Check plugins
If the error only appears on certain pages, deactivate plugins one by one. A crashing plugin also shows up in the PHP error log.
Adjust buffers and workers
For oversized headers or too few PHP workers, the server configuration needs adjusting. On shared hosting, your host takes care of that.
With Cloudflare, test the server directly
If the server is reachable without Cloudflare, the problem is the connection in between, such as a firewall blocking Cloudflare's IP ranges.
Impact on Google.
For Google, a 502 is a server error like 500 or 503. Short outages only slow down crawling. If the errors last several days, pages disappear from the index and only gradually return after the fix.
Frequent short 502s, for example at peak times, are a sign the server is running at its limit. Then it's worth looking at your hosting plan or moving to managed WordPress hosting with enough PHP workers.
Help from a developer
I can take care of it.
The check shows where things go wrong. I am happy to fix it, once or on an ongoing basis.
Good to know
Questions about Error 502?
The most common questions, answered briefly.
Questions about Error 502
What does "502 Bad Gateway nginx" mean?
nginx accepted the request but didn't get a usable response from PHP or the server behind it. The fault is usually PHP, not nginx itself.
What's the difference between 502 and 504?
With 502 the server behind sends a broken response or none at all, the connection fails. With 504 the connection works, but the response takes too long.
Is a 502 caused by my internet connection?
No. If you can see the error page, your internet worked. The problem is between the servers of the website.
All status codes at a glance.
2xx: Success
- 200OKAll good: the server understood the request and delivers the page.
- 201CreatedThe request succeeded and created something new, for example a record via an API.
- 204No ContentSuccessful, but the response has no body. Typical for APIs and background requests, not for regular pages.
3xx: Redirects
- 301Moved PermanentlyPermanent redirect: the page now lives at a new address. Search engines switch to the new URL.Causes and fixes →
- 302FoundTemporary redirect: the page is currently available at another address, the original URL stays valid.Causes and fixes →
- 303See OtherRedirect to another page that is fetched with GET, typically after submitting a form.
- 304Not ModifiedThe page has not changed since the last visit, so the browser uses its cached copy. Not an error.
- 307Temporary RedirectTemporary redirect like 302, but the request method (such as POST) is guaranteed to stay the same.
- 308Permanent RedirectPermanent redirect like 301, but the request method (such as POST) is guaranteed to stay the same.
4xx: Client errors
- 400Bad RequestThe server can't process the request because it is malformed, for example due to oversized cookies or a broken URL.Causes and fixes →
- 401UnauthorizedThis page requires you to log in, for example via server-side password protection. No valid credentials, no access.Causes and fixes →
- 403ForbiddenThe server understood the request but refuses access, for example because of file permissions, a firewall or a block.Causes and fixes →
- 404Not FoundThere is no page at this address. It was deleted, moved, or the URL is misspelled.Causes and fixes →
- 405Method Not AllowedThe address exists but doesn't accept this kind of request, such as a POST where only GET is allowed.
- 408Request TimeoutThe server waited too long for the complete request and closed the connection, often on a slow connection.
- 410GoneThe page was removed deliberately and permanently and won't come back. A clearer signal than 404.Causes and fixes →
- 429Too Many RequestsToo many requests in a short time: a rate limit or bot protection is temporarily slowing down access.Causes and fixes →
- 451Unavailable For Legal ReasonsThe page is blocked for legal reasons, for example by an official order or a country block.
5xx: Server errors
- 500Internal Server ErrorGeneric server error: something went wrong while building the page. With WordPress it is usually a plugin, theme or PHP issue.Causes and fixes →
- 501Not ImplementedThe server doesn't know or support the request method. Rare on regular websites.
- 502Bad GatewayA server in front (proxy, nginx, CDN) didn't get a usable response from the actual server, often because PHP crashed.
- 503Service UnavailableThe server is temporarily unavailable due to maintenance or overload. Try again later.Causes and fixes →
- 504Gateway TimeoutA server in front waited too long for the actual server to respond and gave up.Causes and fixes →
- 520Web Server Returned an Unknown ErrorCloudflare error: the server behind Cloudflare sent an empty, invalid or unexpected response.
- 521Web Server Is DownCloudflare error: the server behind Cloudflare refuses the connection, so it is down or blocking Cloudflare.
- 522Connection Timed OutCloudflare error: Cloudflare couldn't establish a connection to the server behind it in time.
- 523Origin Is UnreachableCloudflare error: the server behind it can't be reached, often because of a wrong IP address in the DNS records at Cloudflare.
- 524A Timeout OccurredCloudflare error: the connection to the server works, but it didn't respond in time (100 seconds by default).
- 525SSL Handshake FailedCloudflare error: the encrypted connection between Cloudflare and the server behind it could not be established.
- 526Invalid SSL CertificateCloudflare error: the SSL certificate on the server behind Cloudflare is invalid or expired (with SSL mode "Full (strict)").
No status code: connection errors
- ×Server not found (DNS)There is no server for this domain: it has expired, is misconfigured, or the record with the IP address is missing.Causes and fixes →
- ×Connection refusedThe server is known but doesn't accept connections. The web server isn't running or a firewall is blocking.
- ×TimeoutThe server didn't answer in time. It is overloaded, stuck, or not reachable at all.
- ×Certificate error (SSL)The SSL certificate has expired, doesn't cover this domain, or the certificate chain is incomplete. Browsers show a warning.Causes and fixes →

