Consul on OSX selects localhost address as the advertise address

We have a set of MacOS machines with Consul installed. Consul is configured to run as a Launch Daemon with the following configuration file


{
    "addresses": {
        "http": "{{ GetInterfaceIP \"en0\" }}"
    },
    "client_addr": "127.0.0.1",

    "data_dir": "#{consul_data_path}",

    "disable_host_node_id": true,
    "disable_remote_exec": true,
    "disable_update_check": true,

    "dns_config": {
        "allow_stale": true,
        "max_stale": "87600h",
        "node_ttl": "30s",
        "service_ttl": {
            "*": "30s"
        }
    },

    "log_level": "INFO",

    "ports": {
        "dns": 8600,
        "http": 8500,
        "serf_lan": 8301,
        "serf_wan": 8302,
        "server": 8300
    },

    "server": false,

    "skip_leave_on_interrupt": true,

    "verify_incoming": false,
    "verify_outgoing": false
}

In this case en0 is the name of the ethernet network interface.

For some reason when Consul starts up it will grab the IP address of the machine from en0 but after a while it will advertise itself as 127.0.0.1 (using the IP of the lo0 loopback interface). Restarting the daemon after logging in will reset the advertising address back to the proper machine IP address.

After the machine reboots but before I log in Consul registers like this:

After I log in and restart the daemon, Consul registers like this

Shortly after that it dies with an error message and gets stuck in a restart - crash loop. The error message for that is:

memberlist: Got bind error: Failed to start UDP listener on "0.0.0.0" port 8301: listen udp 0.0.0.0:8301: bind: address already in use

Which I suspect is linked to the fact that consul was already running. A listing of processes doesn’t show an additional Consul running though, so I have no idea what is going on.