Search code examples
load-balancinghaproxy

Haproxy 503 Service Unavailable No server is available to handle this request


I have balancing host

192.168.1.12

receive input HTTP/HTTPS traffic

and balancing on backends

10.0.1.12
10.0.1.13

Use

HA-Proxy version 1.8.4-1deb90d 2018/02/08

config

global
    log         127.0.0.1 local2

    chroot  /var/opt/rh/rh-haproxy18/lib/haproxy
    pidfile     /var/run/rh-haproxy18-haproxy.pid
    maxconn     20000
    daemon

    # turn on stats unix socket
    stats socket /var/opt/rh/rh-haproxy18/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          15s
    timeout server          15s
    timeout http-keep-alive 5s
    timeout check           3s
    maxconn                 20001

frontend http_frontend
    bind *:80
    default_backend http_backend

backend http_backend
    mode http
    server server1 10.0.1.12:8081 check
    server server1 10.0.1.13:8081 check

Start service OK

Check curl

# curl -iv 10.0.1.12:8081
# curl -iv 10.0.1.13:8081

Return OK

Why curl http://localhost

return 503 Service Unavailable No server is available to handle this request.

?


Solution

  • here is my haproxy.cfg file hope this will help you to resolve your issue.

    # Nur Load Balancer #
    
    frontend tomcat-service
            bind *:8081
            default_backend tomcat-server
            mode http
    
    backend tomcat-server
            balance roundrobin
            server mfsys-cm-01 192.168.10.31:8080 check
            server mfsys-cm-02 192.168.10.30:8080 check
    
    listen stats
            bind *:8082
            stats enable
            stats hide-version
            stats show-node
            stats uri /stats
            stats auth admin:mypassword
            stats refresh 5s
    

    i got same error when i access stats, and solution was simple i was not giving proper url as it should be http://192.168.10.1:8082/stats