# Nginx: [error] no live upstreams while connecting to upstream (503/502)

**Code:** `no live upstreams while connecting to upstream` · **Category:** Nginx / Apache · **Seen on:** Nginx, Linux

All servers in an `upstream` group are marked unavailable, so Nginx has nothing to proxy to.

## Meaning

After repeated failures (`max_fails`/`fail_timeout`), Nginx temporarily marks servers down. Fix the backends, tune `max_fails=3 fail_timeout=10s`, or add health checks. If you have a single server in the upstream, one failure can mark it down — consider `max_fails=0` or using `proxy_pass` directly.

## Common causes

- All upstream servers failed health/connection checks
- `max_fails` too low with intermittent errors
- Backend overloaded/crashed
- Wrong upstream addresses
- Single-server upstream marked down

## Quick fix

1. Fix/restart backends and read the preceding connect() errors
2. Tune `max_fails`/`fail_timeout` or set `max_fails=0` for single server
3. Add more servers and health checks

## Detailed fix by platform

### Nginx

1. `upstream app { server 127.0.0.1:3000 max_fails=3 fail_timeout=10s; keepalive 16; }`

## How to diagnose

1. **Servers** — Reachable?
2. **max_fails** — Reached?
3. **Count** — Single backend?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nginx-apache/nginx-no-live-upstreams)
