Lab-tested: PHP 8.4.27 app behind Python 3.13.5 proxy · 2 Dec 2026 · Reproduced and fixed in our lab
Fix Box — Try This First (10 Seconds)
These four codes look alike and mean different things. The layer that failed decides which one you see.
- Read the exact code, not just “server error”.
- 500 = the app itself failed. 502/504 = the proxy could not use the app.
- 503 = the server is deliberately unavailable. Check maintenance first.
The Exact Symptoms
All four show a plain error page to visitors. Behind the page, four different failures are possible.
A 500 comes from the application. A 502 and 504 come from a proxy or gateway in front of it.
What We Reproduced in the Lab
We put one PHP app behind one reverse proxy and triggered each code on purpose. The proxy had a two-second upstream timeout.
A fatal error in the app returned 500 through the proxy. Killing the app entirely returned 502 Bad Gateway.
A maintenance flag on the proxy returned 503 Service Unavailable. An app that slept five seconds returned 504 Gateway Timeout.
Same site, same proxy, four codes. Only the failing layer changed.
The Fixes
For 500, fix the application: read its error log and repair the fatal. Our PHP 500 Error guide covers the common deaths.
For 502, the upstream is down or unreachable. Restart or repair the app process, then confirm the proxy can connect.
# nginx: name the upstream and bound the wait
location / {
proxy_pass http://127.0.0.1:9000;
proxy_connect_timeout 2s;
proxy_read_timeout 30s;
}
For 503, check for maintenance mode, overload, or a deliberate block. For 504, the app is alive but too slow; profile the slow request.
Decision Table
| Code | Failing layer | First check |
|---|---|---|
| 500 | Application code/config | App error log |
| 502 | Proxy cannot reach app | Is the app process running? |
| 503 | Server unavailable by design or overload | Maintenance flag, capacity |
| 504 | Proxy waited too long | Slow request, timeout settings |
What Did Not Work
Restarting the proxy fixed none of our four cases. The proxy was healthy; it was reporting honestly.
Raising the proxy timeout hid the 504 without fixing the slow app. The page just failed later, or loaded painfully slowly.
Prevention
Monitor the app and the proxy separately. One health check per layer tells you which code to expect before visitors do.
Set up Prevent 500 Errors monitoring, and ship changes via WordPress Staging and Safe Updates. Verify codes live with the 500 Error Checker.
For 503 specifically, our sister site covers it in depth: 503 Service Unavailable. The 500 home base is 500 Internal Server Error.
FAQ
Is 502 worse than 500? Neither is “worse”. They point at different layers; the fix location differs.
Why does the same failure show different codes on different hosts? The proxy and timeout setup in front of the app decides. Same bug, different wrapper.
Can a 500 turn into a 504? Yes. If the app hangs instead of crashing, the proxy times out and reports 504.
Does 503 hurt SEO more than 500? A short, honest 503 with Retry-After is the correct signal for maintenance. Long outages hurt either way.
Which log do I read first? The log of the layer that returned the code: app log for 500, proxy log for 502/504.
Sources and date
Lab tests run 2 Dec 2026: PHP 8.4.27 app, Python 3.13.5 proxy. References checked live on the same date.
- RFC 9110 §15.6.1: https://www.rfc-editor.org/rfc/rfc9110.html
- MDN — 500: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500
- MDN — 502: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/502
- MDN — 503: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/503
- MDN — 504: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/504
- nginx — proxy module: https://nginx.org/en/docs/http/ngx_http_proxy_module.html





Leave a Reply