HAProxy returns `503 Service Unavailable — No server is available to handle this request.`
BeginnerTroubleshootingLoad balancers and reverse proxies
Answer
Likely causes → Every server in the backend is DOWN (failed health checks) or in maintenance, or the request matched a backend with no servers because of an ACL/use_backend mistake.
Diagnose →
echo "show servers state" | sudo socat stdio /run/haproxy/admin.sock
echo "show stat" | sudo socat stdio /run/haproxy/admin.sock | cut -d, -f1,2,18,37 | column -s, -t
sudo journalctl -u haproxy | grep -i 'is DOWN'
Fix → Fix the backend or the health check (option httpchk GET /healthz, correct port), or correct the routing ACL. A server in MAINT needs set server be_app/web1 state ready.
Prevent → Enable the stats page or Prometheus exporter and alert when a backend's active server count drops.
More on Load balancers and reverse proxies
nginx returns `502 Bad Gateway` and the error log says `connect() failed (111: Connection refused) while connecting to upstream`.Beginnernginx returns `504 Gateway Time-out` with `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAn ALB target group shows all targets `unhealthy` with `Health checks failed with these codes: [404]`.BeginnerAn ALB returns sporadic `502`s, and access logs show `elb_status_code=502` with `target_status_code=-`. Load is low.Intermediatenginx logs `upstream prematurely closed connection while reading response header from upstream`.Intermediatenginx error log shows `no live upstreams while connecting to upstream` and every request gets 502.Intermediate