Im running HAProxy with 3 Apache servers as backend servers. problem is every 2 or 3 request ive got 503 Service Unavailable error and in log files i have this message :

 Oct 19 14:46:57 HAProxy1-www haproxy[31107]: [19/Oct/2015:14:46:57.501] http-in http-in/<NOSRV> -1/-1/-1/-1/0 503 213 - - SC-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"

i checked google , mailing lists and irc find out SC flag is connection refuse happening between haproxy and backend server , i have no firewalls and all servers are in same subnet. i use this options in my haproxy.conf

        log /dev/log    local0 err
        log /dev/log    local1 err
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy

        # Default SSL material locations
        ca-base /etc/ssl/certs
        crt-base /etc/ssl/private

        # Default ciphers to use on SSL-enabled listening sockets.
        # For more information, see ciphers(1SSL). This list is from:
        #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
        ssl-default-bind-options no-sslv3

        log     global
        mode    http
        option  httplog
        option  dontlognull
        option  forwardfor
        option  http-server-close
        option  redispatch
        timeout connect 5000
        timeout client  50000
        timeout server  50000
        retries 3
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http
frontend http-in
        mode http
        # default_backend host_httpd-in
        acl host_http-in hdr_sub(host) -i domain.ir
        use_backend host_httpd-in if host_http-in
backend host_httpd-in
        mode http
        balance roundrobin
        # balance leastconn
        option httpclose
        option forwardfor
        # option forwardfor header X-Forwarded-For
        # reqidel ^X-Real-IP
        #cookie JSESSIONID prefix
        #cookie SERVERID insert indirect
        # option httpchk HEAD /index.html HTTP/1.0
        server www1       check
        server www2       check
        server www3       check
userlist stats-auth
    group admin    users arash
    user  arash    insecure-password arash123
    group readonly users system
    user  system  insecure-password haproxy

listen stats
    use_backend stats_auth
backend stats_auth
    stats enable
    stats hide-version
    stats uri /stats
    acl AUTH       http_auth(stats-auth)
    acl AUTH_ADMIN http_auth_group(stats-auth) admin
    stats http-request auth unless AUTH
    stats admin if AUTH_ADMIN

any suggestions for me ?

  • Are you seeing any flapping of your backend servers? – GregL Oct 19 '15 at 12:13
  • no servers are ready for responding to requests i tested each one of them and all things works – Arash Shams Oct 20 '15 at 5:43
  • What I meant was, are you seeing them come up and down in the HAProxy logs? – GregL Oct 20 '15 at 11:50
  • 1
    yes i checked all of them worked correctly but i think its all about cookie tagging, i remov now ed all of cookie settings and everything worked correctly – Arash Shams Oct 20 '15 at 18:45
  • In your posted configuration, the cookie directives are commented out. If they were enabled in your tests, it's possible that you'd need to revise your config to make session persistence work properly. – GregL Oct 20 '15 at 19:31

Try to use

bind *:80

instead of


  • 6
    This answer seems highly implausible to me given the sporadic nature of the problem. – kasperd Apr 28 '16 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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