diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp
index 777f459626d181e7a31d4aded6daa43281272a39..cf9b6ed3ddd501bb1b389225247b5464966f1e4e 100644
--- a/src/upnp/upnp_context.cpp
+++ b/src/upnp/upnp_context.cpp
@@ -617,6 +617,10 @@ UPnPContext::getCurrentIgd() const
 void
 UPnPContext::enforceAvailableMappingsLimits()
 {
+    // If there is no valid IGD, do nothing.
+    if (!isReady())
+        return;
+        
     for (auto type : {PortType::TCP, PortType::UDP}) {
         int pendingCount = 0;
         int inProgressCount = 0;