
The short answer: in both cases there is one server in front (the one that receives the visitor) and another behind (the one that runs PHP or the application). With a 502 the one behind gave an invalid answer or stopped answering; with a 504 it took too long. Almost always it is a slow, stopped or starved program, not a domain problem.
What the site needs
| What | What to do |
| 502 Bad Gateway | The server behind failed or closed the connection halfway: a PHP process that died, a stopped application, a wrong port in the proxy. |
| 504 Gateway Timeout | The server behind took longer than allowed: a heavy program, a slow query, a request to an outside service that does not answer. |
| One page, or the whole site? | One page: usually that program. The whole site: the service behind is stopped or out of resources. |
| On a VPS | The application (Node.js, Python, PHP-FPM) may be stopped, or the proxy points to the wrong port: Nginx in front of a container. |
| With Cloudflare in front | The error may come from Cloudflare when it cannot reach your server: Cloudflare errors 520 to 526. |
Getting started
|
|
|
|
|
|
| If the error comes and goes at the same hour, it is load: a heavy scheduled task, a bot crawling the site or a campaign. Measure before raising limits: What makes a difference when the site is slow. |
| The general picture of error codes is in Website errors explained. For a real peak: Preparing for a traffic spike. |
|
The error persists and you do not know why? Open a ticket with the address, the time and what you were doing. Open a support ticket |
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon) See plans |
- 0 Users Found This Useful











