diff --git a/src/shrpx.cc b/src/shrpx.cc index 386aabfb..c0d3d161 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -715,6 +715,13 @@ int create_tcp_server_socket(UpstreamAddr &faddr, addrinfo *res, *rp; rv = getaddrinfo(node, service.c_str(), &hints, &res); +#ifdef AI_ADDRCONFIG + if (rv != 0) { + // Retry without AI_ADDRCONFIG + hints.ai_flags &= ~AI_ADDRCONFIG; + rv = getaddrinfo(node, service.c_str(), &hints, &res); + } +#endif // AI_ADDRCONFIG if (rv != 0) { LOG(FATAL) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6") << " address for " << faddr.host << ", port " << faddr.port diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index f29c0db3..82db8598 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -3761,6 +3761,13 @@ int resolve_hostname(Address *addr, const char *hostname, uint16_t port, addrinfo *res; rv = getaddrinfo(hostname, service.c_str(), &hints, &res); +#ifdef AI_ADDRCONFIG + if (rv != 0) { + // Retry without AI_ADDRCONFIG + hints.ai_flags &= ~AI_ADDRCONFIG; + rv = getaddrinfo(hostname, service.c_str(), &hints, &res); + } +#endif // AI_ADDRCONFIG if (rv != 0) { LOG(FATAL) << "Unable to resolve address for " << hostname << ": " << gai_strerror(rv);