diff --git a/cmake/FindWrapResolv.cmake b/cmake/FindWrapResolv.cmake
index 159df9b60d8..7d6b3fa50f7 100644
--- a/cmake/FindWrapResolv.cmake
+++ b/cmake/FindWrapResolv.cmake
@@ -40,9 +40,8 @@ check_cxx_source_compiles("
 
 int main(int, char **argv)
 {
-    res_state statep = {};
-    int n = res_nmkquery(statep, 0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
-    n = res_nsend(statep, NULL, 0, NULL, 0);
+    int n = res_mkquery(0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
+    n = res_send(NULL, 0, NULL, 0);
     n = dn_expand(NULL, NULL, NULL, NULL, 0);
     return n;
 }
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
index 4262ad58d50..47524f954af 100644
--- a/src/network/kernel/qdnslookup_unix.cpp
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -25,6 +25,10 @@ QT_REQUIRE_CONFIG(libresolv);
 
 #include <array>
 
+#if !defined(__GLIBC__)
+#  include "resolv_compat.h"
+#endif
+
 #ifndef T_OPT
 // the older arpa/nameser_compat.h wasn't updated between 1999 and 2016 in glibc
 #  define T_OPT     ns_t_opt
@@ -133,7 +137,7 @@ static int
 prepareQueryBuffer(res_state state, QueryBuffer &buffer, const char *label, ns_rcode type)
 {
     // Create header and our query
-    int queryLength = res_nmkquery(state, QUERY, label, C_IN, type, nullptr, 0, nullptr,
+    int queryLength = res_mkquery(QUERY, label, C_IN, type, nullptr, 0, nullptr,
                                    buffer.data(), buffer.size());
     Q_ASSERT(queryLength < int(buffer.size()));
     if (Q_UNLIKELY(queryLength < 0))
@@ -170,7 +174,7 @@ static int sendStandardDns(QDnsLookupReply *reply, res_state state, QSpan<unsign
 
     auto attemptToSend = [&]() {
         std::memset(buffer.data(), 0, HFIXEDSZ);        // the header is enough
-        int responseLength = res_nsend(state, qbuffer.data(), qbuffer.size(), buffer.data(), buffer.size());
+        int responseLength = res_send(qbuffer.data(), qbuffer.size(), buffer.data(), buffer.size());
         if (responseLength >= 0)
             return responseLength;  // success
 
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 3b0e2d333aa..8eeb3cc2c0d 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -18,6 +18,10 @@
 #  include <resolv.h>
 #endif
 
+#if !defined(__GLIBC__)
+#  include "resolv_compat.h"
+#endif
+
 #ifndef _PATH_RESCONF
 #  define _PATH_RESCONF "/etc/resolv.conf"
 #endif
diff --git a/src/network/kernel/resolv_compat.h b/src/network/kernel/resolv_compat.h
new file mode 100644
index 0000000..4f0e852
--- /dev/null
+++ b/src/network/kernel/resolv_compat.h
@@ -0,0 +1,29 @@
+#if !defined(__GLIBC__)
+/***************************************************************************
+ * resolv_compat.h
+ *
+ * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
+ * Note: res_init() is actually deprecated according to
+ * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
+ **************************************************************************/
+#include <string.h>
+
+static inline int res_ninit(res_state statp)
+{
+	int rc = res_init();
+	if (statp != &_res) {
+		memcpy(statp, &_res, sizeof(*statp));
+	}
+	return rc;
+}
+
+static inline int res_nclose(res_state statp)
+{
+	if (!statp)
+		return -1;
+	if (statp != &_res) {
+		memset(statp, 0, sizeof(*statp));
+	}
+	return 0;
+}
+#endif
