OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

fix(runtime) Avoid windows reserved port

Open happyherp opened this issue 8 months ago • 2 comments

  • [ ] This change is worth documenting at https://docs.all-hands.dev/
  • [x] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

When starting a docker container under windows, ports reserved by windows are skipped. Before this could make the docker container fail to start.

End-user friendly description of the problem this fixes or functionality that this introduces.

Under windows, sometimes docker containers would fail to start.


Give a summary of what the PR does, explaining any non-trivial design decisions.

simply changing the ip to 0.0.0.0 triggers the error, if the port is reserved under windows.


Link of any specific issues this addresses.

https://github.com/All-Hands-AI/OpenHands/issues/7540

happyherp avatar Apr 06 '25 12:04 happyherp

Test

I ran this locally. Windows 10 wsl, docker in wsl. For about a week(any many container restarts) this particular problem did not happen anymore.

It did happen occasionally, when I was working on a branch without the fix.

So I am confident, this fixes it.

happyherp avatar Apr 06 '25 13:04 happyherp

I keep getting the error about 50% of the time when starting a docker runtime, if I do not have the fix in.


  File "/home/ubuntu/.cache/pypoetry/virtualenvs/openhands-ai-TKHEuTrS-py3.12/lib/python3.12/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation) from e
docker.errors.APIError: 500 Server Error for http+docker://localhost/v1.48/containers/897285c81e324766fe999dce54686c07f3c455b7792c1d009d8f7a94e575cd47/start: Internal Server Error ("Ports are not available: exposing port TCP 0.0.0.0:50143 -> 127.0.0.1:0: listen tcp 0.0.0.0:50143: bind: An attempt was made to access a socket in a way forbidden by its access permissions.")

happyherp avatar Apr 18 '25 09:04 happyherp

Looks still same issue there, fixed by below restart in my end:

net stop winnat
net start winnat

yuqisun avatar May 16 '25 14:05 yuqisun