From ba9da1bcaca1645fc3273e75cdd60c647c8c6979 Mon Sep 17 00:00:00 2001 From: Egor Eliseev Date: Thu, 23 Jul 2026 14:54:17 +0000 Subject: [PATCH] PY-91091 Debugger error on Docker Compose interpreter Close the pre-created loopback socket BEFORE binding the new one. For a Docker Compose target the resolved local endpoint is a wildcard address (0.0.0.0), which overlaps the still-open loopback (127.0.0.1) socket on the same port - binding the new socket first fails with "Address already in use". Merge-request: IJ-MR-214921 Merged-by: Egor Eliseev (cherry picked from commit d3a001becd1d34b427f1b3ef0621313e156098ce) IJ-MR-214921 GitOrigin-RevId: 864db56aecb288f33324c3405fd319093d2c4322 --- python/src/com/jetbrains/python/debugger/PyDebugRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index 5a38292d6531..56638db4a330 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -313,14 +313,14 @@ public class PyDebugRunner implements ProgramRunner { || (hostInetAddress.isLoopbackAddress() && serverSocket.getInetAddress().isLoopbackAddress())) { return serverSocket; } - var newSocket = new ServerSocket(port, 0, hostInetAddress); + // Close the pre-created loopback socket BEFORE binding the new one. try { serverSocket.close(); } catch (IOException e) { LOG.warn("Failed to close the original server socket", e); } - return newSocket; + return new ServerSocket(port, 0, hostInetAddress); } private static void closeServerSocket(@NotNull ServerSocket serverSocket, @NotNull Throwable cause) {