diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index ca6e1b4..e396bbd 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -497,7 +497,12 @@ void P2PServer::load_peer_list() hints.ai_flags = AI_ADDRCONFIG; addrinfo* result; - const int err = getaddrinfo(nodes[i], nullptr, &hints, &result); + int err = getaddrinfo(nodes[i], nullptr, &hints, &result); + if (err) { + LOGWARN(4, "getaddrinfo failed for " << nodes[i] << ": " << gai_strerror(err) << ", retrying with IPv4 only"); + hints.ai_family = AF_INET; + err = getaddrinfo(nodes[i], nullptr, &hints, &result); + } if (err == 0) { for (addrinfo* r = result; r != NULL; r = r->ai_next) { const char* addr_str; diff --git a/src/util.cpp b/src/util.cpp index a8f0a00..9f697e6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -420,7 +420,12 @@ bool resolve_host(std::string& host, bool& is_v6) hints.ai_flags = AI_ADDRCONFIG; addrinfo* r = nullptr; - const int err = getaddrinfo(host.c_str(), nullptr, &hints, &r); + int err = getaddrinfo(host.c_str(), nullptr, &hints, &r); + if (err) { + LOGWARN(4, "getaddrinfo failed for " << host << ": " << gai_strerror(err) << ", retrying with IPv4 only"); + hints.ai_family = AF_INET; + err = getaddrinfo(host.c_str(), nullptr, &hints, &r); + } if ((err == 0) && r) { const char* addr_str = nullptr; char addr_str_buf[64];