<p>I'm using dns names for my backend servers in my hsproxy.cfg like</p>

<pre><code>backend s0
    server server0 server0.x.y.local:8080

backend s1
    server server1 server1.x.y.local:8080
</code></pre>

<p>The name resolution works fine after startup. But as soon as the ipadress of a backendserver changes, requests to haproxy take a long time (like 25 seconds) and then respond with 503 (reason: SC). It doesn't update or reresolve the dns names. But a <code>curl</code> on that machine works fine so the operating system updates the ip adress for those dns entries correctly. So it looks like haproxy is caching the ip adress on startup and never changes them.</p>

<p>I'm using haproxy as a pod inside of a kubernetes cluster (not sure if that matters).</p>

<p>From what I read in the offical docs, the libc option should use the operating systems resolve? I have tried putting <code>init-addr libc</code> but it didn't help, haproxy still responds with long running 503 forever while on the machine, dns resolves perfectly.</p>

<p>I have also seen that there are some fine tunings possible when using a <code>resolver</code> entry, where you can configure refresh times etc. Is this possible without hardcode nameservers in haproxy.cfg and just use the ones from the operating system?</p>

<p>Seems to be correct that HAProxy does cache the resolved IP unless you tell it otherwise.</p>

<p>As you already found the configuration using a resolver and a custom check interval should do the trick (<code>resolvers dns check inter 1000</code> and <code>hold valid</code>), but you are also right that this requires a <code>resolvers</code> section as well. Since HAProxy 1.9 you can use <code>parse-resolv-conf</code> to use the local resolver:</p>

<pre><code>resolvers mydns
  parse-resolv-conf
  hold valid 10s

backend site-backend
  balance leastconn
  server site server.example.com:80 resolvers mydns check inter 1000
</code></pre>

<p>The HAProxy documentation can help you with further configuration: <a href="https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#5.3.2-parse-resolv-conf" rel="noreferrer">https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#5.3.2-parse-resolv-conf</a></p>
