I stumbled upon this after creating a systemd service, which started on boot, and called http://127.0.0.1:8094/some-path, which failed with:
Address family for hostname not supported

This was because I forgot to set After=network.target, so interfaces other than lo 127.0.0.1 didn’t have their IP set (yet).
Because of this line:
|
NS.addrFlags = [NS.AI_ADDRCONFIG] |
… the whole thing failed, according to
man getaddrinfo:
If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4
addresses are returned in the list pointed to by res only if the
local system has at least one IPv4 address configured, and IPv6
addresses are returned only if the local system has at least one IPv6
address configured. The loopback address is not considered for this
case as valid as a configured address. This flag is useful on, for
example, IPv4-only systems, to ensure that getaddrinfo() does not
return IPv6 socket addresses that would always fail in connect(2) or
bind(2).
But even then, calls to 127.0.0.1 shouldn’t fail.
Probably http-client shouldn’t even be setting AI_ADDRCONFIG. There is really no reason to be using it — e.g. curl doesn’t.
I stumbled upon this after creating a systemd service, which started on boot, and called
http://127.0.0.1:8094/some-path, which failed with:This was because I forgot to set
After=network.target, so interfaces other thanlo 127.0.0.1didn’t have their IP set (yet).Because of this line:
http-client/http-client/Network/HTTP/Client/Connection.hs
Line 149 in c1c6ffa
… the whole thing failed, according to
man getaddrinfo:But even then, calls to 127.0.0.1 shouldn’t fail.
Probably
http-clientshouldn’t even be settingAI_ADDRCONFIG. There is really no reason to be using it — e.g.curldoesn’t.