diff --git a/src/upnp/upnp_context.h b/src/upnp/upnp_context.h
index b5fb188bd84fef0cde1acb7ff69287c7d8ff4101..843f9fe6349281c9fd54ceef22b32c82d41709f5 100644
--- a/src/upnp/upnp_context.h
+++ b/src/upnp/upnp_context.h
@@ -158,11 +158,11 @@ private:
     uint16_t chooseRandomPort(const IGD& igd, PortType type);
 
 #if HAVE_LIBNATPMP
-    std::thread pmpThread_ {};
     std::mutex pmpMutex_ {};
     std::condition_variable pmpCv_ {};
     std::shared_ptr<PMPIGD> pmpIGD_ {};
     std::atomic_bool pmpRun_ {true};
+    std::thread pmpThread_ {};
 
     void PMPsearchForIGD(const std::shared_ptr<PMPIGD>& pmp_igd, natpmp_t& natpmp);
     void PMPaddPortMapping(const PMPIGD& pmp_igd, natpmp_t& natpmp, GlobalMapping& mapping, bool remove=false) const;