How to fix Could Not Resolve Address Blocking Error In Haproxy
I am quite new to devops and it's a whole fascinating world that is opening to me. Recently I came over an issue while reconfiguring haproxy servers. I decided to deploy them as containers on Docker network bridge, replacing static IP addresses by containers and node names. Doing so, I faced an error like this when a container is not started or a node is absent at startup:
[ALERT] 336/141922 (1565) : Failed to initialize server(s) addr.
Annoying as haproxy is expected to detect if servers are up or down to route trafic properly. There is no issue when using IP addresses though they are by far less convenient when working with containers.
The solution is simple though. It consists in adding this
line in the defaults
section of the configuration:
default-server init-addr last,libc,none
To paraphrase the documentation, the important word here is
none
. It ensures that haproxy will not fail on startup in case
of a name resolution failure.