A 502 Bad Gateway error occurs when one server acting as a gateway or proxy receives an invalid response from another server upstream. Modern websites often place a CDN, load balancer, reverse proxy, or platform router in front of the application. The gateway is reachable, but it cannot obtain a usable answer from the service behind it. The exact cause may be a crashed application, network interruption, protocol mismatch, or timeout.

Before making changes, capture the exact URL, time, browser message, and the network used for the test. That small record prevents circular troubleshooting and gives hosting or development support something concrete to investigate.

Where the error occurs

The browser connects to the public gateway successfully. That gateway then forwards the request to an origin server, application process, container, or another proxy. If the upstream closes the connection unexpectedly, sends malformed data, or cannot be reached, the gateway returns 502. This means the public edge may be healthy while the application behind it is failing. Draw the request path before troubleshooting so you know which connection produced the error.

Common technical causes

Application processes may crash, restart, or listen on the wrong port. A deployment can change the upstream address without updating proxy configuration. Firewalls may block traffic between layers. TLS settings can fail when the proxy expects HTTPS but the origin speaks HTTP, or when hostname verification rejects the origin certificate. Resource exhaustion and oversized headers can also cause gateways to reject an otherwise running service.

A practical rule is to change one variable at a time and retest from outside the affected system. If several settings are changed together, a temporary recovery can be mistaken for a real fix and the original cause remains hidden.

What visitors should do

Wait briefly and refresh once because transient 502 errors often clear during a restart or failover. Avoid repeatedly submitting forms, especially purchases, because the upstream may process the action even when the gateway fails to return confirmation. Try the homepage to see whether one route is affected. If the error continues, report the full URL, time, and any request identifier shown on the page.

What operators should check first

Review gateway and upstream logs for the same request. Confirm the application process is running, healthy, and listening on the configured address. Test the upstream directly from the gateway network using the expected protocol and hostname. Compare the incident time with deployments, autoscaling events, certificate changes, and resource limits. If a release clearly caused the issue, roll back rather than repeatedly restarting unstable code.

Website owners should keep access, contacts, and recovery instructions documented before an incident. Visitors should avoid repeated submissions or rapid refreshes when transactions may be involved, because a delayed response does not always mean the action failed.

Timeouts and capacity

Although gateway timeout is usually reported as 504, some platforms return 502 for upstream resets caused by slow or overloaded applications. Inspect request duration, worker availability, connection pools, memory, and queue depth. Identify expensive endpoints and failing dependencies. Increasing proxy timeouts may hide symptoms while users wait longer and workers remain occupied. Fix the constrained component or degrade non-essential features deliberately.

Prevent repeat gateway failures

Use health checks that remove unhealthy instances from rotation, graceful shutdown so deployments finish active requests, and readiness checks before new instances receive traffic. Align proxy protocols, ports, header limits, and TLS expectations through configuration management. Alert on rising 502 rates by route and upstream. StatusPulse can show that the public URL returns 502, while gateway logs identify which internal hop failed.

Practical next steps

Use this guide as an incident checklist rather than a list to rush through. Begin with the step titled “Where the error occurs”, continue to “Common technical causes”, and record what changes after each test. Then review “What visitors should do” and “What operators should check first” before applying a permanent fix. Finish with “Timeouts and capacity” and “Prevent repeat gateway failures”. This order keeps the investigation focused, makes handovers clearer, and reduces the chance of solving one symptom while leaving the underlying problem active. Note the final cause, the action that restored service, and one follow-up task. That short record becomes a useful starting point if the same warning appears again. Retest from a separate network before closing the incident, because local caches can make an incomplete recovery look successful.

Save the full URL, timestamp with timezone, test location, HTTP status or browser message, and the last known successful check. Include recent deployments, DNS edits, certificate changes, or hosting notices when they are relevant. A screenshot can help, but copy the error text as well so it remains searchable. Good evidence shortens support conversations, prevents repeated tests, and makes it easier to compare a new incident with an older one.

After any apparent recovery, verify more than the homepage. Test the exact failing URL, important forms, authentication, and any revenue-producing path. Continue observing for long enough to catch repeated restarts or caches that briefly hide the problem. You can start with a quick external test on the StatusPulse homepage, then continue with the logs and provider tools relevant to the failing layer. Keep the evidence with your incident notes so future troubleshooting begins with facts instead of repeating the same uncertain checks.