502 Bad Gateway: The server was acting as a gateway and received an invalid response from upstream. 502 Bad Gateway means a server that sits in front of your application, such as a load balancer, reverse proxy or CDN, received an invalid response from the application behind it. In practice it usually means the application process crashed, was restarting, or is not listening where the proxy expects. During a deploy you may see a short burst of 502s while old processes stop and new ones start.
What should you keep in mind with 502 Bad Gateway?
To debug it, look one step further back. The proxy's own logs tell you which upstream failed, and the application or container logs tell you why. Common causes are a crashed PHP-FPM or Node process, a container that fails its start command, or a wrong port in the proxy configuration. Zero-downtime deploys and health checks prevent most of the deploy-time 502s.
Use when an HTTP request returns an unexpected status code (4xx or 5xx, or a redirect loop), when a user pastes an error like "419 Page Expired", "422 Unprocessable Content", "502 Bad Gateway" or "CORS error", or when debugging API calls between a frontend and a Laravel/PHP or Node backend. Finds the cause from the status code, headers and logs before changing code.
Full Sentry SDK setup for PHP. Use when asked to "add Sentry to PHP", "install sentry/sentry", "setup Sentry in PHP", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for PHP applications. Supports plain PHP, Laravel, and Symfony.