5xx Server error
502 Bad Gateway
A gateway or proxy got an invalid response from the upstream server.
nginx, a load balancer or CDN tried to reach your application and the connection failed or returned garbage.
Common causes and fixes
- The application process may have crashed or not be listening — check that it’s running and the port matches the proxy config.
- Check the proxy error log (e.g. “connect() failed” or “upstream prematurely closed connection”).
- Out-of-memory kills and restarts during deploys are common causes.
- For PHP-FPM, check that the socket path and pool are correct.
Example response
HTTP/1.1 502 Bad Gateway
Date: Thu, 22 Oct 2026 08:00:00 GMT Check a URL’s status with curl -I https://example.com, which prints the status line and headers.