diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2194,6 +2194,16 @@
         int64_t nANow = GetAdjustedTime();
         int nTries = 0;
         while (!interruptNet) {
+            // If we didn't find an appropriate destination after trying 100
+            // addresses fetched from addrman, stop this loop, and let the outer
+            // loop run again (which sleeps, adds seed nodes, recalculates
+            // already-connected network ranges, ...) before trying new addrman
+            // addresses.
+            nTries++;
+            if (nTries > 100) {
+                break;
+            }
+
             CAddrInfo addr = addrman.SelectTriedCollision();
 
             // SelectTriedCollision returns an invalid address if it is empty.
@@ -2213,16 +2223,6 @@
                 break;
             }
 
-            // If we didn't find an appropriate destination after trying 100
-            // addresses fetched from addrman, stop this loop, and let the outer
-            // loop run again (which sleeps, adds seed nodes, recalculates
-            // already-connected network ranges, ...) before trying new addrman
-            // addresses.
-            nTries++;
-            if (nTries > 100) {
-                break;
-            }
-
             if (!IsReachable(addr)) {
                 continue;
             }