Troubleshooting guide
Nginx "no live upstreams": how to fix it
Nginx marked every server in the upstream group as failed, so it had nowhere to send the request and returned a 502 immediately.
3 min read10 sectionsUpdated
On this page
# The first errors before "no live upstreams"
sudo grep -nE 'no live upstreams|upstream (timed out|prematurely|sent)|connect\(\) failed' /var/log/nginx/error.log | tail -30
# Can Nginx reach each backend?
curl -sv -o /dev/null --max-time 5 http://10.0.0.5:8080/health 2>&1 | tail -3
# The upstream configuration
sudo nginx -T 2>/dev/null | grep -A8 '^\s*upstream'Fixes
Restore the backends, or fix what is making them fail. Run at least two. For a single-server upstream, set max_fails=0, as marking the only server as down helps nothing. Tune max_fails=3 fail_timeout=15s. Do rolling restarts, removing one at a time. For dynamic IPs, use the resolver directive along with a variable in proxy_pass, or the resolve parameter in a zone-based upstream.
Why it can outlast the outage
Say a backend was briefly overloaded and returned errors for five seconds. Nginx marks it down for the fail_timeout, sending all traffic to the remaining servers, which are now busier and may begin to fail too. Soon, every server has been marked down, although each was only struggling. The result is a total outage from a partial one. Sensible max_fails, enough spare capacity, and backends that shed load cleanly with a fast response all help to stop this cascade.
Catch it automatically
Log the message, chart 502s per upstream and use independent uptime checks on each backend's health endpoint, so that you can separate backend failure from Nginx's view.
Related reading
- 504 Gateway Timeout: causes and fixes: What causes 504 Gateway Timeout errors, how timeouts stack across CDN, load balancer and Nginx, and how to find and fix the slow request.
- Nginx "upstream timed out (110)": how to fix it: Fix Nginx upstream timed out (110: Connection timed out) while reading response header: find the slow request, tune proxy timeouts and fix the backend.
- PHP maximum execution time exceeded: how to fix it: Fix PHP Maximum execution time of 30 seconds exceeded: why external waits may not count, which timeouts line up with Nginx, and how to move long work away.
- MySQL server has gone away: causes and how to fix it: Fix MySQL error 2006 server has gone away: idle timeouts, oversized packets, server restarts and connection pools holding connections that have died.
- Cloudflare error 521: web server is down: Fix Cloudflare error 521 "Web server is down": the origin refused the connection. Check the web server, firewall rules for Cloudflare IPs and DNS.
- Kubernetes readiness probe failed: how to fix it: Fix Kubernetes readiness and liveness probe failures: slow startup, wrong ports, overloaded health endpoints and dependency checks that cause cascading outages.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.