diff --git a/src/upnp/upnp_control.cpp b/src/upnp/upnp_control.cpp
index e2a2b58db1a02c162a7dab7ea8850307f581be8f..4e3be9d60481ba39dadbfd817ed73aafa87485d8 100644
--- a/src/upnp/upnp_control.cpp
+++ b/src/upnp/upnp_control.cpp
@@ -46,8 +46,10 @@ Controller::~Controller()
 {
     /* remove all mappings */
     removeMappings();
+#if HAVE_LIBUPNP
     if (listToken_ and upnpContext_)
         upnpContext_->removeIGDListener(listToken_);
+#endif
 }
 
 bool
@@ -64,9 +66,11 @@ Controller::setIGDListener(IGDFoundCallback&& cb)
 {
     if (not upnpContext_)
         return;
+#if HAVE_LIBUPNP
     if (listToken_)
         upnpContext_->removeIGDListener(listToken_);
     listToken_ = cb ? upnpContext_->addIGDListener(std::move(cb)) : 0;
+#endif
 }
 
 bool