I use HaProxy to forward traffic to a backend server which has a dns name instead of network address:

backend default-backend
    server external somedomain.com:80

The problem is that there is a situation when it can become not resolvable. In this case HaProxy says:

Server default-backend/external is going DOWN for maintenance (DNS NX status). 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. backend default-backend has no server available!

I would like HaProxy to check for DNS resolution again and start forwarding traffic whenever target DNS name is resolvable again. The problem is that I have to declare resolvers section and at least one nameserver which can resolve such address like this:

resolvers rslvr
    nameserver dns0

What if I do not like to declare any resolvers? I just want HaProxy checked DNS resolution the same way it does on startup. Is it possible?

If I do not use a resolver, backend just stops working and does not check if this domain is available again. Same thing happens when I do not have any nameserver in resolvers section.

Is there any way to omit explicit nameserver declaration or maybe use some default resolver used by HaProxy on startup?

  • What version of HAProxy? (haproxy -v) Jun 3, 2018 at 19:41
  • @Michael-sqlbot 1.8.8, not that old :)
    – Kirill
    Jun 3, 2018 at 19:57
  • I'm not sure you're fixing the right problem. Without resolvers foo on the server line, HAProxy should not try to resolve the host after startup unless that is relatively new behavior. Are you sure it us a resolution problem, or is it that the server address changes, but HAProxy doesn't try to look it up again? Jun 3, 2018 at 20:44
  • @Michael-sqlbot Ok, without resolvers I can't achieve what I want, as I understand it was never possible and there is no such new feature. Anyway I do not like the idea of specifying nameservers explicitly. So I ask if there is a kind of an alias on default nameserver which would resolve the same way HAProxy does on startup?
    – Kirill
    Jun 3, 2018 at 21:16
  • 1
    Your question was very unclear. I see now, what you want -- use the system resolver settings so that runtime resolution is the same as startup, without explicit configuration. I've seen discussion about this on the mailing list, but I don't think that feature will be included until 1.9. If you are running this in AWS, then nameserver vpc is a magic value that works, regardless of your VPC's IP address range. Jun 3, 2018 at 22:45

1 Answer 1


haproxy version 1.9 introduced a new parameter for the resolvers section which removes the need to manually list the nameservers.


See their docs for more info but essentially this allows you to replace

resolvers mydns
  nameserver dns1
  nameserver dns2
  hold valid           10s


resolvers mydns
  hold valid           10s

assuming your resolv.conf (which is read by haproxy when you don't have a resolvers section) has and configured.

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.