Troubleshooting / symptôme

One site returns 502 Bad Gateway

The proxy or front server does not get a valid response from the upstream application server.

⌚ About 3 min read
View my favorites
Real-world problem · V2

Quick troubleshooting view

What you are seeing

The proxy or front server does not get a valid response from the upstream application server.

Likely causes
  1. Backend arrested
  2. PHP-FPM unavailable
  3. Timeout
First checks
  1. Identify the frontal
  2. Test backend directly
  3. Read the logs proxy and application
Recommended actions
  1. Restore the backend
  2. Correct the Address/port of the proxy
  3. Adapt timesouts only after understanding the cause
Start Symptom → Cause →
WebIntermediate.

The proxy or front server does not get a valid response from the upstream application server.

Important: relevez toujours le message d’erreur exact et l’heure du problème avant de modifier la configuration. Les actions proposées doivent être adaptées à votre environnement.

Causes probables

  • Backend arrested
  • PHP-FPM unavailable
  • Timeout
  • Reverse proxy misconfigured
  • Saturated application

Diagnostic étape par étape

  1. 1

    Identify the frontal

    Determine whether Nginx, Apache, CDN or proxy returns 502.

  2. 2

    Test backend directly

    If possible, check the upstream service.

  3. 3

    Read the logs proxy and application

    Look for timeout, connection, or reset.

  4. 4

    Check resources

    CPU, RAM, workers and connections can be saturated.

Solutions possibles

  • Restore the backend
  • Correct the Address/port of the proxy
  • Adapt timesouts only after understanding the cause
Quand escalader ?

Scramble to the host if the backend or server resources are out of your control.

Operational context

A 502 Bad Gateway means the proxy, gateway or load balancer could not obtain a valid response from the upstream application. Isolate DNS, edge/proxy health, upstream reachability, TLS/SNI and application response time before changing the public site configuration.

Step-by-step checks

  1. Confirm the failure is specific to one hostname and compare the response from an external client, the reverse proxy itself and a direct request to the upstream service where permitted.
  2. Resolve the public and internal DNS names and verify that the proxy is targeting the intended IP, port and protocol rather than a stale or private address.
  3. Check the upstream TCP/TLS connection, SNI/Host header and certificate chain; a healthy TCP port can still fail when the virtual host or TLS identity is wrong.
  4. Correlate the 502 timestamp with reverse-proxy and application logs, paying attention to connection refused, timeout, premature close and invalid-header messages.

Useful verification commands

Use commands only on systems you administer and capture the read-only output before making a configuration change.

curl -I https://example.com/
curl -vk https://example.com/
nslookup example.com

How to validate the result

The public hostname must return the expected application response through the proxy and the upstream health check must remain stable without connection errors or timeout spikes.

Evidence to keep

Keep DNS answers, response headers, upstream endpoint/port, proxy error log lines, application log lines and the exact UTC/local timestamp of a failed request.

Frequently asked question

Does a 502 mean the website application is always down?

No. The application may be healthy while the reverse proxy uses the wrong address, port, protocol, SNI, certificate trust or timeout policy.

Related BAOI resources: IT tools · procedures · IT dictionary.

♡ 0