What it means: nginx had no available server left in the upstream group, so it returned 502 without connecting.
Free online tool — HTTP status code checker: instant results, no signup.
Requests the address and shows the status code and what the server sends back.
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.
The round-robin balancer skips a server when any of these hold (ngx_http_upstream_round_robin.c):
| Condition | Configured by | What to check |
|---|---|---|
Failed attempts reached max_fails within fail_timeout | server ... max_fails=1 fail_timeout=10s (both are the defaults) | Earlier connect() failed or upstream timed out lines for each server |
Marked down | server ... down; | A server left disabled after maintenance |
At max_conns | server ... max_conns=N | All servers at their connection limit under load |
| Already tried for this request | proxy_next_upstream | Each 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).
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.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/healthdown flags and limits: nginx -T 2>/dev/null | grep -A10 'upstream app_servers'.fail_timeout or, for an upstream without a shared-memory zone, reload nginx to clear the counters: nginx -t && systemctl reload nginx.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.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.
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.
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.
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.
Enter a code or keyword — instant result with description.
1xx Informational, 2xx Success, 3xx Redirect, 4xx Client Error, 5xx Server Error.
For each code: typical causes and concrete steps to resolve.
How each code affects indexing and link juice transfer in Google.
choosing correct status
redirect optimization
5xx error diagnostics
landing page check
HTTP monitor alerts when response code changes or 5xx appears.
Sign up freeThe 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.
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.
502 Bad Gateway. The upstream field in the log shows the group name because no server was selected.
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.
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.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.