# Updating server address through admin API when current address is empty

**URL:** <https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550>\
**Category:** Help!\
**Created:** [November 25, 2019, 6:36pm UTC](https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550 "2019-11-25T18:36:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aitorpazos](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aitorpazos/32/918_2.png) [@aitorpazos](https://discourse.haproxy.org/u/aitorpazos)\
**Post date:** [November 25, 2019, 6:36pm UTC](https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550/1 "2019-11-25T18:36:02Z")

</div>

Hi community,

I’m facing an issue where HAProxy refuses to update backend servers target address when their current address is empty.

The target address is empty in my case because in some situations the backend services may not be deployed and therefore not resolvable as they haven’t been registered in consul.

My resolvers config is as follow:

> defaults  
> […]  
> default-server init-addr last,libc,none
> 
> resolvers dns  
> # Uses default resolution  
> parse-resolv-conf  
> resolve\_retries 3  
> […]

and backend are defined using server-template:

> listen listen-name  
> bind “${LISTEN\_BIND}”
> 
> server-template my-server- 1-6 “${BACKEND\_ENDPOINT}” check resolvers dns resolve-prefer ipv4

When `BACKEND_ENDPOINT` resolves, I get up to 6 servers configured that I can update, but when it doesn’t resolve at start, all servers are set with empty address and I am unable to update their address through the API, getting the following message:

> Update for the current server address family is only supported through configuration file

I see in `server.c:3801` it is checked if the current address is `AF_INET` or `AF_INET6` but in this situations that condition doesn’t match as current address is empty. However, wouldn’t it be possible to set it also if `current_addr` is empty?  
E.g.:

> if ((sizeof(current\_addr) != 0) && (ret != AF\_INET) && (ret != AF\_INET6)) {

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/jerome/32/984_2.png) [@jerome](https://discourse.haproxy.org/u/jerome)\
**Post date:** [November 25, 2019, 9:25pm UTC](https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550/2 "2019-11-25T21:25:31Z")

</div>

Hi,  
you should use init-addr on your server line.  
[https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#init-addr](https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#init-addr)

---

<div class="post-metadata">

**Author:** ![aitorpazos](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aitorpazos/32/918_2.png) [@aitorpazos](https://discourse.haproxy.org/u/aitorpazos)\
**Post date:** [November 26, 2019, 10:28am UTC](https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550/3 "2019-11-26T10:28:07Z")

</div>

Thanks for your reply @jerome  
Setting the init-addr to a dummy IP instead of `none` as the last option did help running the `set server */* addr *` command.  
However, the new IP is not taking effect and the old one keeps being the one configured. Is HAProxy overwrtting it as it will be checking the DNS entries configured for the server? Is there a way to update that DNS entry from the API? (This message suggests that: [WARNING] 329/102409 (6) : backend/server-3 changed its IP from 10.5.0.31 to 10.5.128.89 by DNS cache.)  
I tried switching from `server-template` to individual `server` lines but the behavior is the same.

---

<div class="post-metadata">

**Author:** ![Baptiste](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Baptiste](https://discourse.haproxy.org/u/Baptiste)\
**Post date:** [November 27, 2019, 5:53am UTC](https://discourse.haproxy.org/t/updating-server-address-through-admin-api-when-current-address-is-empty/4550/4 "2019-11-27T05:53:40Z")

</div>

You can’t use both DNS resolver and API, or resolver will always erase changes provided by the API.  
Simply remove resolvers then and use API only.

Or use resolvers and update your DNS server updated to what you need.
