diff --git a/src/dht.cpp b/src/dht.cpp
index 970d8e237d3a59c57116ebf4f4fbf642a2366944..909546888c62973a6080a815c3b5134928137900 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -879,7 +879,7 @@ Dht::trySearchInsert(const std::shared_ptr<Node>& node)
         if (s.insertNode(node, now)) {
             inserted = true;
             scheduler.edit(s.nextSearchStep, s.getNextStepTime(now));
-        } else
+        } else if (not s.expired and not s.done)
             break;
         ++it;
     }
@@ -891,7 +891,7 @@ Dht::trySearchInsert(const std::shared_ptr<Node>& node)
         if (s.insertNode(node, now)) {
             inserted = true;
             scheduler.edit(s.nextSearchStep, s.getNextStepTime(now));
-        } else
+        } else if (not s.expired and not s.done)
             break;
     }
     return inserted;