J. JieraltField Notes
Technical guide

A reverse proxy returns 502: verify the upstream hop by hop

Use proxy logs, container networking and the app listen address to narrow down a 502 before changing DNS or restarting services.

What a 502 tells you—and what it does not

A 502 generally means the proxy did not receive a valid response from its upstream. It does not identify whether the cause is DNS, a port, a protocol mismatch or an application process. Start with the proxy error at the matching timestamp, then test each hop.

Follow the request path

  1. Proxy config: Does the upstream host, port and protocol match what the app actually serves? Do not configure an HTTP upstream as HTTPS by assumption.
  2. Network path: Request the upstream from the proxy container or host—not only from your laptop.
  3. App listener: A containerized app often needs to listen on 0.0.0.0; binding only to its own 127.0.0.1 prevents other containers from reaching it.
  4. App state: Check whether the process exited, is still starting, or fails its health check.
docker compose logs --since=10m proxy app
docker compose exec proxy sh -c 'nc -vz app 3000'

Replace the example service names and port. If the proxy image lacks nc, use an available diagnostic method rather than changing the production image just for the test.

Keep evidence when changing settings

Change one upstream parameter at a time. Record the error time, proxy log and connection result, then send one request. Confirm both the response status and app logs before calling it fixed. Never publish full configs, Authorization headers or access tokens.

This is a general workflow; exact error meanings depend on the proxy and version. A 502 alone is not a reason to reboot the server.

References

Still not working after these steps?

Send me the error and your environment for a free first diagnosis. Hands-on help is quoted before any work starts.

Get a free checkor ask the forum
Want new fixes as they land?Subscribe via RSS →