Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(docker-runtime): adjust default port ranges to avoid Windows ephemeral ports (#9924)

llamantinod5cdecea2123
diff --git a/openhands/runtime/impl/docker/docker_runtime.py b/openhands/runtime/impl/docker/docker_runtime.py
index 29230693cc..24d8d8acba 100644
--- a/openhands/runtime/impl/docker/docker_runtime.py
+++ b/openhands/runtime/impl/docker/docker_runtime.py
@@ -1,4 +1,5 @@
import os
+import platform
import typing
from functools import lru_cache
from typing import Callable
@@ -44,6 +45,12 @@ VSCODE_PORT_RANGE = (40000, 49999)
APP_PORT_RANGE_1 = (50000, 54999)
APP_PORT_RANGE_2 = (55000, 59999)
+if os.name == 'nt' or platform.release().endswith('microsoft-standard-WSL2'):
+ EXECUTION_SERVER_PORT_RANGE = (30000, 34999)
+ VSCODE_PORT_RANGE = (35000, 39999)
+ APP_PORT_RANGE_1 = (40000, 44999)
+ APP_PORT_RANGE_2 = (45000, 49151)
+
def _is_retryablewait_until_alive_error(exception: Exception) -> bool:
if isinstance(exception, tenacity.RetryError):