Why can't HAProxy connect to my local server when my browser can?

43 views Asked by At

I'm on Mac OS. When I go to http://localhost:8085 in my web browser I see my Nginx server working correctly but my backend configured like:

frontend api_gateway
    bind :8080
    mode http
    default_backend nginx

backend nginx
    mode http
    server nginx localhost:8085

When going to http://localhost:8080 I'm getting the error:

503 Service Unavailable

No server is available to handle this request.

1

There are 1 answers

0
mjaggard On

In my case this was due to Nginx listening on 127.0.0.1 which is an IPv4 address but HAProxy was connecting on ::1 the IPv6 address.

To fix it I changed the line from

server nginx localhost:8085

to

server nginx 127.0.0.1:8085

Although another option would be to configure Nginx to listen on IPv6 as well.