Interview Prep/Networking/Load balancers and reverse proxies

nginx error log shows `no live upstreams while connecting to upstream` and every request gets 502.

IntermediateTroubleshootingLoad balancers and reverse proxies
Answer

Likely causes → Every server in the upstream block is marked failed by passive health checking (max_fails within fail_timeout). One short outage or a burst of errors can mark all of them down at once, and nginx then refuses to try any until fail_timeout expires.

Diagnose →

grep -B3 'no live upstreams' /var/log/nginx/error.log | head -20   # what failed first?
nginx -T | grep -A10 'upstream app'

Fix → Fix the underlying failure first. Then tune: server 10.0.1.10:8080 max_fails=3 fail_timeout=10s;, and avoid tiny upstream pools. Note that proxy_next_upstream codes such as http_500 also count as failures.

Prevent → Use active health checks (NGINX Plus, HAProxy, Envoy, or an LB) and alert when more than half the pool is down.

All Networking questions Roadmap: Networking for DevOps

More on Load balancers and reverse proxies