How to Fix 502 Bad Gateway Error

Quick answer
A 502 Bad Gateway error means a gateway or proxy server got an invalid response from the main server. Reload the page, clear cache and try later; site owners should check that the origin server, PHP-FPM and CDN settings are working.
What does “502 Bad Gateway” mean?
HTTP 502 means one server (like a CDN or reverse proxy) could not get a proper reply from another.
What causes it?
- Origin server down or overloaded
- PHP-FPM or app process crashed
- CDN or firewall misconfiguration
- DNS changes not yet updated
Steps to try
Stop when the issue is resolved.
- Reload the page after a minute.
- Clear browser cache or try another browser.
- Flush DNS on your computer.
- Site owners: restart the web server and PHP-FPM.
- Site owners: check CDN (for example Cloudflare) origin settings and server logs.
Need more support? Check the official help: MDN Web Docs: HTTP response status codes
FAQs
Is 502 my internet's fault?
Rarely. It is almost always the website's servers.
How is 502 different from 504?
502 is an invalid reply; 504 is no reply in time.
By Ethan Walker
·