diff --git a/httplib.h b/httplib.h
index 9312227..225e73d 100644
--- a/httplib.h
+++ b/httplib.h
@@ -156,6 +156,9 @@ using socket_t = SOCKET;
 #include <ifaddrs.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#ifdef __linux__
+#include <resolv.h>
+#endif
 #include <netinet/tcp.h>
 #ifdef CPPHTTPLIB_USE_POLL
 #include <poll.h>
@@ -1821,6 +1824,9 @@ socket_t create_socket(const char *host, int port, int socket_flags,
   auto service = std::to_string(port);
 
   if (getaddrinfo(host, service.c_str(), &hints, &result)) {
+#ifdef __linux__
+    res_init();
+#endif
     return INVALID_SOCKET;
   }