Proxies, Load Balancers & CDNsIntermediate

502s during every deploy, for exactly eight seconds

Symptoms

  • Each rolling deploy produces a burst of 502 Bad Gateway for ~8 s, then recovers on its own.
  • The application logs contain no errors and no trace of the failed requests.
  • Error rate is 100% for those seconds even though there are three replicas.
  • The proxy in front is nginx; the app is a Node service on port 8080.
# nginx error.log during the deploy
2026/08/25 09:12:03 [error] 1188#0: *44120 connect() failed (111: Connection refused)
    while connecting to upstream, client: 203.0.113.9, server: api.example.com,
    request: "GET /v1/orders HTTP/1.1", upstream: "http://10.0.3.14:8080/v1/orders"
2026/08/25 09:12:03 [error] 1188#0: *44121 connect() failed (111: Connection refused)
    while connecting to upstream, ... upstream: "http://10.0.3.14:8080/v1/orders"
2026/08/25 09:12:11 [notice] upstream 10.0.3.14:8080 back to healthy

# nginx.conf (relevant part)
upstream api { server 10.0.3.14:8080; }         # a single upstream
location / { proxy_pass http://api; }

# deploy script
systemctl restart api        # stop, then start; the app takes ~8 s to boot

Investigate

Inspect areas in any order (0/6 inspected). When you think you know the root cause, commit to it.

The proxy error log
The upstream definition
The deploy procedure
DNS resolution of the upstream
Is this a 504?
nginx proxy timeouts