How to Fix HAProxy Backend Server Down Error
In this tutorial, you'll learn about How to Fix HAProxy Backend Server Down Error. We cover key concepts, practical examples, and best practices.
HAProxy shows backend_name/server_name DOWN in the stats page and requests return 503 Service Unavailable — the backend server is failing health checks or is unreachable.
The Problem
$ echo "show stat" | socat /var/run/haproxy.sock stdio | grep DOWN
backend,server_name,0,0,0,0,,0,0,0,0,DOWN,...
Step-by-Step Fix
Step 1: Check health check settings
backend backend_servers
option httpchk GET /health
http-check expect status 200
default-server inter 5s fall 3 rise 2
server web1 10.0.0.1:80 check
server web2 10.0.0.2:80 check
Step 2: Verify server connectivity
curl -I http://10.0.0.1:80/health
Step 3: Enable a server manually
echo "enable server backend_servers/web1" | socat /var/run/haproxy.sock stdio
Step 4: Put a server in maintenance
echo "disable server backend_servers/web2" | socat /var/run/haproxy.sock stdio
Step 5: Check HAProxy logs
tail -f /var/log/haproxy.log
Step 6: Adjust check interval for slow servers
server web3 10.0.0.3:80 check inter 10s fall 5 rise 3
Prevention Tips
- Set realistic health check intervals (5-10s for most services)
- Use
fall 3minimum to avoid flapping - Configure backup servers for redundancy
- Add
option allbackupsto use all backup servers when all primaries are down
Common Mistakes with backend down
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
These mistakes appear frequently in real-world HAPROXY code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro