Skip to content
RU

no live upstreams while connecting to upstream: What nginx Is Telling You

What it means: nginx had no available server left in the upstream group, so it returned 502 without connecting.

  1. Find the earlier error that marked servers failed
  2. Bring the backends back up
  3. Review max_fails and fail_timeout
  4. Add a backup server if needed

Test your URL now

Requests the address and shows the status code and what the server sends back.

What "no live upstreams" means

The message is logged at the error level by ngx_http_upstream_connect() when the balancer returns "busy", that is, when it cannot offer a single peer (ngx_http_upstream.c). Because nginx was trying to connect at that moment, the log line reads:

[error] 1234#1234: *5678 no live upstreams while connecting to upstream, client: 198.51.100.7, server: example.com, request: "GET / HTTP/1.1", upstream: "http://app_servers/", host: "example.com"

The client receives 502 Bad Gateway: the failure type falls into the default branch of ngx_http_upstream_next(), which maps to NGX_HTTP_BAD_GATEWAY. Note the upstream: field: it shows the group name (app_servers), not an IP, because no server was chosen.

This line is almost never the root cause. It is the consequence of earlier failures: connect() failed (111: Connection refused), upstream timed out or similar errors marked the servers as unavailable, and for the next requests nginx had nobody left to try.

When a server counts as unavailable

The round-robin balancer skips a server when any of these hold (ngx_http_upstream_round_robin.c):

ConditionConfigured byWhat to check
Failed attempts reached max_fails within fail_timeoutserver ... max_fails=1 fail_timeout=10s (both are the defaults)Earlier connect() failed or upstream timed out lines for each server
Marked downserver ... down;A server left disabled after maintenance
At max_connsserver ... max_conns=NAll servers at their connection limit under load
Already tried for this requestproxy_next_upstreamEach server failed once in this request; nginx ran out of peers to retry

The upstream module documentation adds an important exception: "If there is only a single server in a group, max_fails, fail_timeout and slow_start parameters are ignored, and such a server will never be considered unavailable" (ngx_http_upstream_module). With one server line the message therefore points at down or max_conns. Careful: a hostname in a server line that resolves to several addresses becomes several servers, and then the failure counting applies.

Which events count as a failure is set by proxy_next_upstream: errors, timeouts and invalid headers always count; http_500, http_502, http_503, http_504 and http_429 count only when listed (proxy_next_upstream).

How to fix it

  1. Read the lines before it.
    grep -E 'upstream|no live' /var/log/nginx/error.log | tail -50
    The first errors per server name the real fault: refused, timed out, reset.
  2. Test each backend directly from the nginx host:
    curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' http://10.0.0.11:8080/health
    curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' http://10.0.0.12:8080/health
  3. Check the effective config for forgotten down flags and limits: nginx -T 2>/dev/null | grep -A10 'upstream app_servers'.
  4. Fix the backends (start the service, free memory, fix the crash), then wait fail_timeout or, for an upstream without a shared-memory zone, reload nginx to clear the counters: nginx -t && systemctl reload nginx.
  5. Tune failure detection if short blips take the whole pool out: raise max_fails or lower fail_timeout so a server returns sooner, and do not list http_5xx in proxy_next_upstream unless you mean it.
  6. Add a fallback: server 10.0.0.20:8080 backup; receives traffic only when the primary servers are unavailable.

More on reading nginx logs: how to debug nginx errors.

An upstream block that degrades gracefully

A configuration in which one bad minute does not empty the whole group:

upstream app_servers {
    server 10.0.0.11:8080 max_fails=3 fail_timeout=15s;
    server 10.0.0.12:8080 max_fails=3 fail_timeout=15s;
    server 10.0.0.20:8080 backup;
    keepalive 16;
}

server {
    location / {
        proxy_pass http://app_servers;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_next_upstream error timeout;
        proxy_next_upstream_tries 2;
    }
}

Three failures within 15 seconds are needed before a server is skipped, and the skip lasts 15 seconds, so a single timeout during a deploy no longer removes a server. The backup server only receives requests when both primaries are unavailable, which turns "no live upstreams" into a slower but working site. proxy_next_upstream_tries 2 caps how many servers one request may try, so a broken pool fails fast instead of walking every server. These numbers are a starting point: tune them against how long your backends actually take to recover. If the backends are containers whose addresses change, remember that nginx resolves a hostname in a server line when it loads the configuration (unless the line carries the resolve parameter), so a stale address can look exactly like a dead server until the next reload.

How to confirm the fix

curl -s -o /dev/null -w '%{http_code}\n' https://example.com/
# 200
tail -f /var/log/nginx/error.log | grep --line-buffered 'no live upstreams'
# (nothing new for several minutes)

Give it longer than fail_timeout: servers marked failed come back only after that window. The HTTP status checker confirms what your public URL returns from outside your network.

Related errors

60+ Status CodesComplete HTTP status code reference
Search by CodeQuick search for 200, 301, 404, 500
Categories 1xx–5xxInformational, success, redirects, errors
Examples & CausesWhen it occurs and how to fix it

Why teams trust us

60+
status codes
1xx-5xx
all categories
SEO
ranking impact
Free
online reference

How to use the reference

1

Enter code or keyword

2

Find description and causes

3

Apply recommendations

HTTP Status Codes Reference

HTTP status codes are three-digit numbers that the server returns for every request. They tell the browser and search crawlers what happened: success, redirect, or error.

Quick Search

Enter a code or keyword — instant result with description.

All Categories

1xx Informational, 2xx Success, 3xx Redirect, 4xx Client Error, 5xx Server Error.

Causes & Fixes

For each code: typical causes and concrete steps to resolve.

SEO Impact

How each code affects indexing and link juice transfer in Google.

Who uses this

Developers

choosing correct status

SEO

redirect optimization

DevOps

5xx error diagnostics

Marketers

landing page check

Common Mistakes

Confusing 301 and 302301 is permanent (passes SEO equity), 302 is temporary (does not).
Returning 200 on error"Soft 404s" — a 404 page with status 200 — confuse search engines and stay indexed.
Ignoring 5xx errors500, 503 are server failures. Prolonged episodes remove pages from the index.
Redirect chainsA→B→C instead of A→C slows loading and dilutes SEO equity. Simplify chains.

Best Practices

Use 301 for permanent redirectsThis passes 90–99% of link equity to the new URL.
Return 404 for missing pagesDon't mask 404 as 200 — it hurts SEO and UX.
Monitor 5xx in real timeSet up an HTTP monitor that alerts on 5xx.
Use 410 instead of 404410 Gone means "page permanently removed" — Google de-indexes faster.

Monitor HTTP statuses automatically

HTTP monitor alerts when response code changes or 5xx appears.

Sign up free

Learn more

Sources

Frequently Asked Questions

Why does nginx say "no live upstreams" when my backend is running now?

The servers were marked failed by earlier errors and stay excluded until fail_timeout (10 seconds by default) passes. Requests in that window get 502 even if the backend has already recovered.

Can "no live upstreams" happen with only one backend server?

Yes, but not because of max_fails: a single server is never marked unavailable. It happens when that server is marked down, is at max_conns, or its hostname resolves to several addresses that all failed.

What status code does the client get?

502 Bad Gateway. The upstream field in the log shows the group name because no server was selected.

How do I stop one slow response from taking a server out?

Raise max_fails or lower fail_timeout, and do not add http_500 or http_502 to proxy_next_upstream unless you want error responses counted as failures.

Does reloading nginx clear the failed state?

A reload starts new worker processes, so failure counters kept in worker memory (an upstream without a zone) start fresh. If the backend is still broken, the errors return immediately.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.