Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Almost 1/4 of all requests to a HAProxy instance fail with 503 errors, although the two backend servers are completely healthy and repeated checks on the individual servers return no errors at all.

PHP 5.3 FPM, Nginx, Ubuntu 10.10, HAProxy 1.4.8

Below is my haproxy.cfg:

    log   local0
    log   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user    haproxy
    group   haproxy

defaults http
    log         global
    mode        http
    option      httplog
    option      dontlognull
    retries     3
    option      redispatch
    maxconn     2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000
    errorfile   400 /etc/haproxy/errors/400.htm
    errorfile   403 /etc/haproxy/errors/403.htm
    errorfile   408 /etc/haproxy/errors/408.htm
    errorfile   500 /etc/haproxy/errors/500.htm
    errorfile   502 /etc/haproxy/errors/502.htm
    errorfile   503 /etc/haproxy/errors/503.htm
    errorfile   504 /etc/haproxy/errors/504.htm

listen www
    mode    http
    balance roundrobin
    option  redispatch
    cookie  JSESSIONID prefix
    stats   enable
    stats   auth user:pass
    option  httpclose
    option  forwardfor
    option  httpchk HEAD /health HTTP/1.0
    server  web1 x.x.x.x:8080 weight 1 cookie web1 check inter 1000
    server  web2 y.y.y.y:8080 weight 2 cookie web2 check inter 1000
share|improve this question

You have a wrong IP address for your servers, both have ! That means that the connection will be forwarded to the same IP haproxy received the connection on, so I can deduce that one of your two servers is running on the same host as haproxy.

Please fix that and check your logs. It will probably not fix your 503 but it will bring you back to a sane configuration which has a chance to work. Then please check your logs if you still see 503 so that we can find why haproxy experienced an issue. Most of the time a 503 is caused by the impossibility to connect to a server. It's really possible that you're sending them more connection than they can accept. In this case, use the "maxconn" setting on your "server" lines, this will enable traffic regulation to prevent overflowing.

share|improve this answer
The IPs above are incorrect purely due to me removing them from the public post, in my config they are correct. – James Nov 27 '10 at 17:01
OK, better write "X.X.X.X" then. Anyway, you still need to check what your haproxy logs have to say. There will be termination flags along with the 503 that will indicate you what happened. The timers will help too. – Willy Tarreau Nov 28 '10 at 16:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.