diff --git a/core/src/main/java/io/micronaut/core/io/socket/SocketUtils.java b/core/src/main/java/io/micronaut/core/io/socket/SocketUtils.java
index <HASH>..<HASH> 100644
--- a/core/src/main/java/io/micronaut/core/io/socket/SocketUtils.java
+++ b/core/src/main/java/io/micronaut/core/io/socket/SocketUtils.java
@@ -17,6 +17,7 @@ package io.micronaut.core.io.socket;
 
 import io.micronaut.core.util.ArgumentUtils;
 
+import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
@@ -89,8 +90,10 @@ public class SocketUtils {
         try (Socket socket = new Socket()) {
             socket.connect(new InetSocketAddress(InetAddress.getLocalHost(), currentPort), 20);
             return false;
-        } catch (Throwable e) {
+        } catch (ConnectException e) {
             return true;
+        } catch (Throwable e) {
+            return false;
         }
     }
SocketUtils considers a port available if a ConnectException is thrown during connect attempt (#<I>) (#<I>)