Skip to content

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

Key points

  • max_fails and fail_timeout decide who counts as down.
  • The real failure is logged earlier.
  • One server equals one failure domain.
  • Passive checks only, in open-source Nginx.

What it means

Open-source Nginx detects failures passively: after max_fails errors, by default 1, within fail_timeout, by default 10 seconds, it skips that server for fail_timeout. If all are skipped, requests fail immediately with this message, and the backends may actually be fine by now.

Common causes

  • The backends are genuinely down.
  • A single-server upstream, where one error marks the entire group unavailable.
  • Timeouts counted as failures during a slow spell.
  • Restarts and deployments of every instance at once.
  • Docker or DNS changes, as Nginx resolved the names only when it started.

Diagnose it

Search the log for what happened just before this message.

bash
# 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.

Frequently asked questions

Does Nginx do active health checks?

Open-source Nginx is passive. Active checks are in NGINX Plus or third-party modules.

What are the max_fails defaults?

1 failure within 10 seconds.

Why are backends fine when I test them?

They recovered, but Nginx is still skipping them.

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.