diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java index 5572b5ff383db..7bfa2e328b901 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java @@ -9,6 +9,7 @@ import java.net.InetAddress; import java.net.Socket; import java.net.URI; +import java.net.UnknownHostException; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; @@ -354,7 +355,7 @@ protected void prepare() throws Exception { // make sure the debug port is not used, we don't want to just fail if something else is using it // we don't check this on restarts, as the previous process is still running if (debugPortOk == null) { - try (Socket socket = new Socket(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), port)) { + try (Socket socket = new Socket(getInetAddress(debugHost), port)) { error("Port " + port + " in use, not starting in debug mode"); debugPortOk = false; } catch (IOException e) { @@ -456,6 +457,13 @@ protected void prepare() throws Exception { } } + private InetAddress getInetAddress(String host) throws UnknownHostException { + if (host.equals("localhost")) { + return InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }); + } + return InetAddress.getByName(host); + } + public Collection watchedBuildFiles() { return buildFiles; }