HAProxy 503 Service Unavailable: no server is available to handle this request
Clients are getting 503 Service Unavailable with the message no server is available to handle this request. HAProxy generated this error. Unlike a 500 from your application or a 502 from a broken backend response, a 503 with this message never touched a backend server. HAProxy looked at its own state, concluded it had nowhere to send the request, and answered on its own.
That narrows the diagnostic question to: why did HAProxy believe no server was available? The honest answers are a short list. Every server in the backend is DOWN or in MAINT. The request waited in queue too long and expired. The queue overflowed. The frontend had no matching backend at all. Or connection admission was saturated and the request was rejected before dispatch.
This page walks through distinguishing those causes using the stats socket and log termination codes, and separating a HAProxy-generated 503 from backend 5xx errors and from the neighboring 502 and 504 codes.
What this means
HAProxy returns a 503 to the client in these situations:
- No UP server exists in the backend. All servers are DOWN, in MAINT, or DRAIN. The backend’s aggregate status flips to DOWN, and 100% of requests routed to it get a 503. In TCP mode the equivalent is a connection reset, not a 503.
- The request expired in the queue. The chosen server and backend were at their connection limits, the request waited in queue, and
timeout queuefired before a slot opened. The log shows thesQtermination state. Iftimeout queueis unset, it defaults to the value oftimeout connect. - The queue overflowed. If
maxqueueis set on a server and the queue reaches that limit, further requests are refused rather than queued. With the defaultmaxqueue 0, the queue is unlimited, so overflow-driven 503s only happen when an operator has set a bound. - No backend was selected. ACLs did not match any
use_backendrule and nodefault_backendexists, or the named backend does not exist. The log shows<NOSRV>as the server name. - Admission was saturated. Global or per-frontend
maxconnwas reached, so the connection was rejected before a server was ever considered.
The signature that ties all of these together is the frontend-vs-backend 5xx delta. A HAProxy-generated 503 increments hrsp_5xx on the frontend row but not on any backend or server row, because no server responded. If frontend 5xx is climbing while backend 5xx stays flat, HAProxy is the source.
flowchart TD
A[Client gets 503] --> B{Frontend 5xx rising,
backend 5xx flat?}
B -- No --> C[Errors come from backends.
Not a HAProxy 503 problem.]
B -- Yes --> D{Backend aggregate
status UP?}
D -- DOWN --> E[All servers DOWN or MAINT.
Check per-server status and last_chk.]
D -- UP --> F{qcur nonzero or
sQ in logs?}
F -- Yes --> G[Queue expiry or overflow.
Check scur/slim, maxqueue, timeout queue.]
F -- No --> H{<NOSRV> in logs?}
H -- Yes --> I[Routing gap: no ACL match,
missing default_backend.]
H -- No --> J[Admission saturation:
scur at slim, maxconn reached.]Common causes
| Cause | What it looks like | First thing to check |
|---|---|---|
| All servers DOWN | Backend row status = DOWN, act = 0, last_chk shows L4TOUT/L4CON/L7STS | Per-server status and last_chk in show stat |
| Servers in MAINT or DRAIN | act count lower than configured servers, statuses MAINT/DRAIN | show servers state for who set it and when |
| Queue expiry | qcur nonzero, qtime elevated, sQ termination in logs | qcur, scur/slim per server, timeout queue config |
| maxqueue overflow | 503s under burst load only, maxqueue set in config | Server maxqueue value and queue depth at incident time |
| maxconn saturation | scur at slim, frontend rejecting connections, possibly low CPU | CurrConns vs Maxconn in show info |
| Routing gap | <NOSRV> in logs, 503 on specific URL patterns only | Frontend ACLs and default_backend in the config |
| Health checks green, app broken | Backend 5xx tracks frontend 5xx, servers all UP | Per-server hrsp_5xx; see the dedicated guide below |
Quick checks
All read-only, run against the runtime socket. Adjust the socket path if yours differs.
# 1. Prove the event loop is alive before trusting any stats
echo "show info" | socat unix-connect:/var/run/haproxy.sock stdio | head -1
# 2. Backend aggregate status: DOWN means every request gets a 503
echo "show stat" | socat unix-connect:/var/run/haproxy.sock stdio | \
awk -F, '$2 == "BACKEND" {print $1": status="$18" act="$20" bck="$21}'
# 3. Per-server status and last health check result
echo "show stat" | socat unix-connect:/var/run/haproxy.sock stdio | \
awk -F, '$2 != "FRONTEND" && $2 != "BACKEND" {print $1"/"$2": status="$18" last_chk="$37}'
# 4. Queue depth and session saturation per backend/server
echo "show stat" | socat unix-connect:/var/run/haproxy.sock stdio | \
awk -F, '$2 != "FRONTEND" {print $1"/"$2": qcur="$3" scur="$5" slim="$7}'
# 5. Frontend vs backend 5xx: is HAProxy generating the errors?
echo "show stat" | socat unix-connect:/var/run/haproxy.sock stdio | \
awk -F, '{print $1"/"$2": 5xx="$44}'
# 6. Global connection saturation
echo "show info" | socat unix-connect:/var/run/haproxy.sock stdio | \
grep -E "^(CurrConns|Maxconn|Uptime_sec|Stopping):"
# 7. Termination codes and server names from the log
# Look for sQ (queue expiry), SC/sC (connect refused/timeout), <NOSRV> (no backend)
grep " 503 " /var/log/haproxy.log | tail -20
How to diagnose it
Confirm the 503 is HAProxy-generated. Compare
hrsp_5xxon the frontend row against the backend and server rows for the same window. If the frontend count climbs and backend rows do not, HAProxy produced the errors. If they climb together, the backends are returning the 5xx and this is an application problem, not an availability problem. These counters reset on reload; useUptime_secto sanity-check your deltas.Check backend aggregate status. A BACKEND row with
status = DOWNmeans zero available servers and a guaranteed 503 for every routed request. If DOWN, move to per-server rows:statuspluslast_chktells you why each server was marked out.L4TOUTandL4CONmean HAProxy cannot reach the server at all.L7STSmeans the health check got the wrong HTTP status. Also checkact: a backend can show UP with one surviving server while capacity is critically low.If the backend is UP, look at the queue. Nonzero
qcurwithsQtermination codes in the log means requests waited in queue pasttimeout queueand were expired with a 503. The upstream cause is server saturation: every server atscur == slim, so nothing frees a slot in time. Check per-serverscur/slimandrtime. Slow responses hold slots longer and feed the queue.Check for routing gaps. If the log shows
<NOSRV>as the server name for the 503 requests, HAProxy never selected a backend. Typical reasons: an ACL did not match,default_backendis missing, or ause_backendrule names a backend that does not exist. This often appears after a config change and affects only specific URL patterns or hosts.Check admission limits.
CurrConnsapproachingMaxconninshow info, or a frontendscurat itsslim, means connections were rejected before routing. A useful tell:Idle_pctmay look healthy because HAProxy is not overloaded with work, it is simply full. Highscurwith lowreq_ratepoints at idle or long-lived connections holding slots.Separate from 502 and 504. The termination code in the log disambiguates:
SCmeans the connection to the server was actively refused (likely a 502 or 503),sCmeanstimeout connectfired (503 or 504),sQmeans queue expiry (503), andSH/sHwith a full timeout points attimeout server(504). If you are seeing 504s with servers UP andrtimeclimbing, that is the timeout cascade, not a 503 availability problem.
Metrics and signals to monitor
| Signal | Why it matters | Warning sign |
|---|---|---|
Backend row status | DOWN means 100% of routed requests get 503 | Any production backend DOWN |
act per backend | Active server count; cascade risk when shrinking | Below 50% of configured servers, or 1 remaining |
Frontend minus backend hrsp_5xx delta | Isolates HAProxy-generated errors from backend errors | Delta rising while backend 5xx flat |
qcur / qtime | Requests waiting for a server slot; precedes sQ expiries | Any sustained nonzero value |
Per-server scur/slim | Servers at maxconn feed the queue | Ratio above 90% on all servers in a backend |
CurrConns vs Maxconn | Global admission limit | Ratio above 90% |
last_chk per server | Exact health check failure reason | L4TOUT, L4CON, L7STS appearing |
wretr / wredis | HAProxy masking instability before it becomes 503s | Sustained nonzero rate |
Fixes
All servers DOWN
Fix the health check failure reason, not HAProxy. L4CON/L4TOUT means a network, port, or process problem on the server side. L7STS means the health check endpoint is returning an unexpected status, so verify the endpoint against the application. If several servers are flapping and redistributing load onto survivors, put the worst offenders into MAINT to stop the flap loop while you fix the root cause:
# Disruptive: takes the server out of rotation. Use deliberately.
echo "set server <backend>/<server> state maint" | socat unix-connect:/var/run/haproxy.sock stdio
Queue expiry and overflow
The 503s are a symptom of backend saturation, so the durable fix is capacity: more servers, higher per-server maxconn if the application can absorb it, or faster backend responses. Shorter term, raising timeout queue lets requests wait longer instead of failing, at the cost of longer client-visible latency under saturation. Removing a tight maxqueue converts instant 503s into queued waiting, which is usually better for users but delays the failure signal. Do not just raise every limit without watching qcur and qtime afterward; you can convert fast, visible failures into slow, invisible ones.
Routing gaps
Fix the config: add the missing default_backend, correct the ACL, or point use_backend at a backend that exists. Validate with haproxy -c -f /etc/haproxy/haproxy.cfg before reloading. Config validation catches a nonexistent backend reference, but it cannot catch an ACL that simply never matches your traffic.
maxconn saturation
Determine whether connections are busy or idle. High scur with high req_rate is a genuine traffic surge: raise maxconn (remember the file descriptor budget, roughly maxconn x 2 plus overhead) or scale horizontally. High scur with low req_rate is idle connections holding slots: tighten timeout client and timeout http-request, and investigate long-lived connections with show sess. Remember maxconn is enforced at four levels (global, frontend, backend, per-server); a per-server limit can cause 503s while the global limit has plenty of headroom.
Prevention
- Alert on backend aggregate DOWN with traffic confirmation. Page when a backend is DOWN and the frontend has
req_rate > 0or a rising 5xx rate, sustained past a short grace period, with anUptime_secgate to ignore cold start. - Alert on the frontend-minus-backend 5xx delta. It catches every HAProxy-generated error class (503, 504, 502) faster than per-backend investigation.
- Watch
actper backend, not just aggregate status. A backend at one surviving server is one failure from a 503 storm. Page-worthy when survivors are also loaded (scur/slimhigh orqcur > 0). - Track
qcurandqtimeas leading indicators. Queuing appears beforesQexpiries. Any sustained nonzero queue in a system that normally runs at zero deserves a ticket. - Watch
wretr/wredis. Rising retries mean HAProxy is compensating for instability that will become visible 503s when compensation runs out. - Set
timeout queueand per-servermaxconndeliberately. Defaults are permissive in different ways: unlimited queue time falls back totimeout connect, and servers have no connection limit unless you set one. Both decisions shape how saturation surfaces.
How Netdata helps
- Netdata collects the HAProxy stats CSV continuously, so
hrsp_5xxper frontend, backend, and server becomes a time series. The frontend-minus-backend delta that identifies a HAProxy-generated 503 is a direct chart correlation instead of a manual diff during an incident. - Per-server
status,act, andchkdowntrends show a backend losing servers over hours, which is the most common path to the all-DOWN 503 storm. qcur,qtime, and per-serverscur/slimon the same dashboard let you see queue-driven 503s forming beforetimeout queuestarts expiring requests.- Counter resets on reload are handled automatically, so reload storms do not produce phantom 5xx drops or spikes in the middle of your diagnosis.
- Correlating
econ,wretr, andrtimeper server alongside 5xx rates separates “server unreachable” from “server slow” from “server failing fast” without log diving as the first step.
Related guides
- HAProxy 504 Gateway Timeout: timeout server and the backend timeout cascade
- HAProxy backend losing servers: active server count and cascade risk
- HAProxy backend queue building (qcur): requests waiting for a free server slot
- HAProxy scur approaching slim: the concurrent-session saturation signal
- HAProxy health checks green but the application is broken: when UP does not mean healthy
- HAProxy health check L4TOUT and L4CON: server marked DOWN and unreachable
- HAProxy health check L7STS: server DOWN on the wrong HTTP status
- How HAProxy actually works in production: a mental model for operators
- HAProxy maxconn hierarchy: global, frontend, backend, and per-server limits
- HAProxy maxconn reached: new connections queued and rejected
- HAProxy monitoring checklist: the signals every production proxy needs
- HAProxy monitoring maturity model: from survival to expert






