OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: Always get connection refused in dev container

Open AleKitsune98 opened this issue 6 months ago • 5 comments

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

When starting a new conversation in dev container I get: raceback (most recent call last): File "/app/openhands/server/session/session.py", line 187, in initialize_agent await self.agent_session.start( File "/app/openhands/server/session/agent_session.py", line 130, in start runtime_connected = await self._create_runtime( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/server/session/agent_session.py", line 369, in _create_runtime await self.runtime.connect() File "/app/openhands/runtime/impl/docker/docker_runtime.py", line 177, in connect await call_sync_from_async(self.wait_until_alive) File "/app/openhands/utils/async_utils.py", line 18, in call_sync_from_async result = await coro ^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/utils/async_utils.py", line 17, in coro = loop.run_in_executor(None, lambda: fn(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 338, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 477, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 378, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 420, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 187, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 480, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/runtime/impl/docker/docker_runtime.py", line 436, in wait_until_alive self.check_if_alive() File "/app/openhands/runtime/impl/action_execution/action_execution_client.py", line 128, in check_if_alive response = self._send_action_server_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 338, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 477, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 378, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 400, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 480, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/runtime/impl/action_execution/action_execution_client.py", line 125, in _send_action_server_request return send_request(self.session, method, url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 338, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 477, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 378, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 400, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 480, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/runtime/utils/request.py", line 44, in send_request response = session.request(method, url, timeout=timeout, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/utils/http_session.py", line 31, in request return CLIENT.request(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 825, in request return self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1014, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 249, in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/root/.cache/pypoetry/virtualenvs/openhands-ai-9TtSrW0h-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [Errno 111] Connection refused

OpenHands Installation

Docker command in README

OpenHands Version

No response

Operating System

None

Logs, Errors, Screenshots, and Additional Context

No response

AleKitsune98 avatar Jun 10 '25 09:06 AleKitsune98

This should have been fixed by #8971 a few days ago. Did you start from the 0.41 sources or did you clone the repository? If you've tried one, try the other: it might help pinpoint if this is a regression or the same old issue.

llamantino avatar Jun 10 '25 16:06 llamantino

Thank you for reply, I managed to solve using a vscode dev container. I cloned from the latest commit

AleKitsune98 avatar Jun 11 '25 10:06 AleKitsune98

Thanks for the update. Just to clarify: Did it start working because you updated to the latest version of the repo (with the fix from #8971), or because you changed something in the setup? Or did you just switch from launching the devcontainer manually to using it via VS Code?

Knowing what actually changed will help us confirm if this is resolved or if there's something left to fix or document.

llamantino avatar Jun 11 '25 10:06 llamantino

I just switched from launching the devcontainer manually to using it via VS Code. I used the latest version of the repo. Running it via this tutorial does not work for me https://github.com/All-Hands-AI/OpenHands/blob/main/containers/dev/README.md

AleKitsune98 avatar Jun 11 '25 10:06 AleKitsune98

Thanks for the details! I don’t think the setup in containers/dev is a real devcontainer - it looks like a standard Docker setup meant to be run manually, with optional VS Code attach support. It was the same issue I fixed in #8971. I’ve sent a PR that should fix make docker-dev as well.

llamantino avatar Jun 11 '25 16:06 llamantino