GrepBoard/Manuals
605 manuals ·

HAProxy 503 "No server is available" — find the cause

·Tested on Ubuntu 24.04 · HAProxy 2.8.16 · behavior per the HAProxy 2.8 configuration and management docs·Test scope ↓·7 steps

Got a 503 "No server is available"? Read NOSRV and the termination state in the log, then use show stat to tell DOWN servers, no match and queue expiry.

If a client gets a 503 with the body below, HAProxy found no server to send the request to. The output comes from HAProxy 2.8.16 on port 18631 with the backend stopped and started again; only the client address is replaced with a documentation address.

output
HTTP/1.1 503 Service Unavailablecontent-length: 107cache-control: no-cachecontent-type: text/html <html><body><h1>503 Service Unavailable</h1>No server is available to handle this request.</body></html>

HAProxy generated this body, not your app. The cause is in the log and the runtime API.

[1] Find the 503 line for the same time in the log. Look at the 4th field (backend/server) and the termination state. Field layout is in Reading an HAProxy log line. No server was reached, so the server slot is <NOSRV>.

output
203.0.113.7:58106 [19/Oct/2026:12:55:01.039] web app/<NOSRV> 0/-1/-1/-1/0 503 217 - - SC-- 1/1/0/0/0 0/0 "GET /app/ HTTP/1.1"203.0.113.7:58108 [19/Oct/2026:12:55:01.049] web web/<NOSRV> -1/-1/-1/-1/0 503 217 - - SC-- 1/1/0/0/0 0/0 "GET /other/ HTTP/1.1"203.0.113.7:40034 [19/Oct/2026:12:55:41.288] web app/<NOSRV> 0/2001/-1/-1/2001 503 217 - - sQ-- 2/2/1/0/0 0/1 "GET /app/slow HTTP/1.1"

All three are the same 503 with different causes. The backend field and the termination state tell them apart.

LineBackend fieldStateMeaning
1stappSC--A backend was chosen, but it has no usable server
2ndweb (the frontend name)SC--No backend was chosen
3rdappsQ--Tw is 2001 ms — expired in the queue

[2] Open the runtime API. global needs a stats socket line; reload after adding it. Send commands to the socket with socat.

/etc/haproxy/haproxy.cfg
global    stats socket /run/haproxy/admin.sock mode 600 level admin

[3] Run show stat. It has more than 70 columns, so keep status, weight and check result (fields 18, 19 and 37) with cut. This is right after s1 went down.

console
# echo "show stat" | socat stdio /run/haproxy/admin.sock | cut -d, -f1,2,18,19,37
output
# pxname,svname,status,weight,check_statusweb,FRONTEND,OPEN,,app,s1,DOWN,1,L4CONapp,BACKEND,DOWN,0,api,a1,no check,1,api,BACKEND,UP,1,

When every server in app is DOWN, app,BACKEND is DOWN too, and every request routed to it gets a 503. L4CON means the check failed at the TCP connect step; the reason text is in last_chk (field 57).

output
status=DOWNcheck_status=L4CONlast_chk=Connection refused

[4] show servers state gives the same information. In column 6, srv_op_state, 0 means the server is down (the management manual defines 0 as SRV_ST_STOPPED and 2 as SRV_ST_RUNNING).

console
# echo "show servers state app" | socat stdio /run/haproxy/admin.sock
output
1# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port3 app 1 s1 127.0.0.1 0 0 1 1 8 8 2 0 6 0 0 0 - 18632 - 0 0 - - 0

[5] Bring the server back. With rise 1, one passing check marks it UP and requests return 200. HAProxy logs one line at every state change.

output
[WARNING]  (62744) : Server app/s1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.[ALERT]    (62744) : backend 'app' has no server available![WARNING]  (62744) : Server app/s1 is UP, reason: Layer7 check passed, code: 200, check duration: 1ms. 1 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.

[6] If the server is UP and the log's backend field is the frontend name (web/<NOSRV>), it is the 2nd line above. The path /other/ matched no use_backend condition and there was no default_backend. Fix the condition or add a default_backend.

/etc/haproxy/haproxy.cfg
frontend web    bind 127.0.0.1:18631    acl is_api path_beg /api    use_backend api if is_api    use_backend app if { path_beg /app }
output
[ALERT]    (63187) : config : Proxy 'web': unable to find required use_backend: 'apii'.[ALERT]    (63187) : config : Fatal errors found in configuration.

[7] If the state is sQ-- and Tw equals the timeout queue value (2s), the request expired in the queue. When a server's maxconn is full, requests wait in a queue, and per the configuration manual a request that exceeds timeout queue is dropped with a 503. The test sent three 4-second requests at once to a maxconn 1 server. Two got a 503 after 2.0 s and one got a 200 after 4.0 s. While they wait, the same show stat shows the queue on the backend row.

output
app,s1:       qcur=0 qmax=0 scur=1 slim=1app,BACKEND:  qcur=2 qmax=2 scur=3

Only one request (slim=1) is being served. Before raising timeout queue, find out why the server is slow and whether maxconn fits what the app can handle.

Analyze your HAProxy log in the browser ↗ — nothing is uploaded.

Check it with the HTTP status codes tool ↗ — calculated in your browser.

#haproxy#503