502 Server Error

502 Bad Gateway

An HTTP 502 Bad Gateway error means that a server acting as a gateway or proxy received an invalid or incomplete response from an upstream server it contacted to fulfill the request. This commonly occurs in architectures where a reverse proxy like Nginx or a load balancer sits in front of application servers. End users see a failed page load, while developers need to investigate the communication between the proxy and the backend.

Common causes

  • The upstream application server has crashed, is unresponsive, or is not running
  • Firewall or security group rules blocking traffic between the proxy and the backend server
  • The upstream server is returning malformed HTTP responses or headers
  • DNS resolution failures preventing the gateway from locating the upstream server
  • Network timeouts due to the upstream server taking too long to start sending a response

How to fix it

  • Verify that the upstream application server process is running and listening on the expected port
  • Check proxy configuration to ensure upstream server addresses, ports, and protocols are correct
  • Increase proxy timeout settings (e.g., proxy_read_timeout in Nginx) if the backend needs more time to respond
  • Inspect network connectivity and firewall rules between the proxy and backend servers
  • Review upstream server logs for crashes, out-of-memory errors, or other failures that could produce invalid responses

Detect 502 Bad Gateway errors with Checkend

Checkend monitors your application and alerts you when 502 errors occur, with full request context:

  • Full request details (URL, headers, params)
  • Server-side stack trace and error context
  • Automatic grouping of similar errors
  • Instant notifications when error rates spike

Stop debugging HTTP errors in production

Get full error context and fix issues faster with self-hosted error tracking.