OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: ollama not work

Open namen3645 opened this issue 8 months ago • 1 comments

Is there an existing issue for the same bug?

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

`root@DESKTOP-NK2R4R0:~# docker run -it --rm --pull=always -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik -e LOG_ALL_EVENTS=true -v /var/run/docker.sock:/var/run/docker.sock -v ~/.openhands-state:/.openhands-state -p 3000:3000 --add-host host.docker.internal:host-gateway -e LLM_OLLAMA_BASE_URL="http://host.docker.internal:11434" --name openhands-app docker.all-hands.dev/all-hands-ai/openhands:0.29 0.29: Pulling from all-hands-ai/openhands Digest: sha256:17048b1c9c16574550698020f90371520ae73f5e6b1a2920d04d0e3f8615a8c1 Status: Image is up to date for docker.all-hands.dev/all-hands-ai/openhands:0.29 Starting OpenHands... Running OpenHands as root 18:04:02 - openhands:INFO: server_config.py:38 - Using config class None INFO: Started server process [10] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:3000 (Press CTRL+C to quit) INFO: 172.17.0.1:49884 - "GET /conversations/bb3ad225587d424887cda0d60ea654e2 HTTP/1.1" 200 OK INFO: 172.17.0.1:49884 - "GET /locales/en/translation.json HTTP/1.1" 200 OK INFO: 172.17.0.1:49884 - "GET /api/options/config HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/settings HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /favicon.ico HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/conversations/bb3ad225587d424887cda0d60ea654e2 HTTP/1.1" 200 OK INFO: ('172.17.0.1', 49904) - "WebSocket /socket.io/?latest_event_id=-1&conversation_id=bb3ad225587d424887cda0d60ea654e2&EIO=4&transport=websocket" [accepted] 18:04:06 - openhands:INFO: listen_socket.py:32 - sio:connect: sT35AT7tokp34CD4AAAB 18:04:06 - openhands:INFO: standalone_conversation_manager.py:116 - join_conversation:bb3ad225587d424887cda0d60ea654e2:sT35AT7tokp34CD4AAAB 18:04:06 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:259 - maybe_start_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:262 - start_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:07 - openhands:INFO: docker_runtime.py:140 - [runtime bb3ad225587d424887cda0d60ea654e2] Starting runtime with image: docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik 18:04:07 - openhands:INFO: listen_socket.py:81 - sio:disconnect:sT35AT7tokp34CD4AAAB 18:04:07 - openhands:INFO: standalone_conversation_manager.py:334 - disconnect_from_session:sT35AT7tokp34CD4AAAB:bb3ad225587d424887cda0d60ea654e2 18:04:07 - openhands:ERROR: public.py:70 - Error getting OLLAMA models: HTTPConnectionPool(host='host.docker.internal', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f55e2a0e060>: Failed to establish a new connection: [Errno 111] Connection refused')) INFO: 172.17.0.1:49898 - "GET /api/options/models HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/options/agents HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/options/security-analyzers HTTP/1.1" 200 OK 18:04:08 - openhands:INFO: docker_runtime.py:144 - [runtime bb3ad225587d424887cda0d60ea654e2] Container started: openhands-runtime-bb3ad225587d424887cda0d60ea654e2. VSCode URL: None 18:04:08 - openhands:INFO: docker_runtime.py:155 - [runtime bb3ad225587d424887cda0d60ea654e2] Waiting for client to become ready at http://host.docker.internal:37649... 18:04:26 - openhands:INFO: manage_conversations.py:148 - Initializing new conversation 18:04:26 - openhands:INFO: manage_conversations.py:54 - Creating conversation 18:04:26 - openhands:INFO: manage_conversations.py:58 - Loading settings 18:04:26 - openhands:INFO: manage_conversations.py:61 - Settings loaded 18:04:26 - openhands:INFO: manage_conversations.py:85 - Loading conversation store 18:04:26 - openhands:INFO: manage_conversations.py:87 - Conversation store loaded 18:04:26 - openhands:INFO: manage_conversations.py:93 - New conversation ID: 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:103 - Saving metadata for conversation 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:115 - Starting agent loop for conversation 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:259 - maybe_start_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:262 - start_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:136 - Finished initializing conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:54154 - "POST /api/conversations HTTP/1.1" 200 OK INFO: ('172.17.0.1', 54164) - "WebSocket /socket.io/?latest_event_id=-1&conversation_id=514f3449c5544bc7a724d6e6fda02aa6&EIO=4&transport=websocket" [accepted] INFO: 172.17.0.1:54154 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6 HTTP/1.1" 200 OK 18:04:26 - openhands:INFO: listen_socket.py:32 - sio:connect: aQQ3ZEj-0AQ-vh8UAAAD 18:04:26 - openhands:INFO: standalone_conversation_manager.py:116 - join_conversation:514f3449c5544bc7a724d6e6fda02aa6:aQQ3ZEj-0AQ-vh8UAAAD 18:04:26 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:27 - openhands:INFO: docker_runtime.py:140 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Starting runtime with image: docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik 18:04:28 - openhands:INFO: docker_runtime.py:144 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Container started: openhands-runtime-514f3449c5544bc7a724d6e6fda02aa6. VSCode URL: None 18:04:28 - openhands:INFO: docker_runtime.py:155 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Waiting for client to become ready at http://host.docker.internal:38256... 18:04:34 - openhands:INFO: docker_runtime.py:161 - [runtime bb3ad225587d424887cda0d60ea654e2] Runtime is ready. 18:04:34 - openhands:INFO: base.py:346 - [runtime bb3ad225587d424887cda0d60ea654e2] Selected repo: None, loading microagents from /workspace/.openhands/microagents (inside runtime) 18:04:34 - openhands:INFO: memory.py:233 - Loading user workspace microagents: [] 18:04:34 - openhands:INFO: agent_session.py:161 - Agent session start 18:04:34 - openhands:INFO: agent_controller.py:520 - [Agent Controller bb3ad225587d424887cda0d60ea654e2] Setting agent(CodeActAgent) state from AgentState.LOADING to AgentState.AWAITING_USER_INPUT 18:04:34 - OBSERVATION [Agent Controller bb3ad225587d424887cda0d60ea654e2] AgentStateChangedObservation(content='', agent_state='awaiting_user_input', observation='agent_state_changed') 18:04:54 - openhands:INFO: docker_runtime.py:161 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Runtime is ready. 18:04:54 - openhands:INFO: base.py:346 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Selected repo: None, loading microagents from /workspace/.openhands/microagents (inside runtime) 18:04:54 - openhands:INFO: memory.py:233 - Loading user workspace microagents: [] 18:04:54 - openhands:INFO: agent_session.py:161 - Agent session start 18:04:54 - USER_ACTION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] MessageAction (source=EventSource.USER) CONTENT: test 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.LOADING to AgentState.RUNNING 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.RUNNING 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='running', observation='agent_state_changed') 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] RecallObservation recall_type=RecallType.WORKSPACE_CONTEXT, repo_name=, repo_instructions=..., runtime_hosts={'http://localhost:50727': 50727, 'http://localhost:57045': 57045}, additional_agent_instructions=...

============== [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] LEVEL 0 LOCAL STEP 0 GLOBAL STEP 0

18:04:54 - openhands:INFO: standalone_conversation_manager.py:102 - Conversation 514f3449c5544bc7a724d6e6fda02aa6 connected in 0.03493046760559082 seconds 18:04:54 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:60456 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/web-hosts HTTP/1.1" 200 OK 18:04:54 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:60468 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/vscode-url HTTP/1.1" 200 OK 18:04:54 - openhands:ERROR: agent_controller.py:260 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Error while running the agent (session ID: 514f3449c5544bc7a724d6e6fda02aa6): litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused. Traceback: Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 250, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request raise exc from None File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request response = connection.handle_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 101, in handle_request raise exc File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 78, in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 124, in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp with map_exceptions(exc_map): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ConnectError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 118, in _make_common_sync_call response = sync_httpx_client.post( ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 559, in post raise e File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 537, in post response = self.client.send(req, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1014, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 249, in handle_request with map_httpcore_exceptions(): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/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

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 2825, in completion response = base_llm_http_handler.completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 377, in completion response = self._make_common_sync_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 141, in _make_common_sync_call raise self._handle_error(e=e, provider_config=provider_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 1209, in _handle_error raise provider_config.get_error_class( litellm.llms.ollama.common_utils.OllamaError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/openhands/controller/agent_controller.py", line 258, in _step_with_exception_handling await self._step() File "/app/openhands/controller/agent_controller.py", line 732, in _step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 122, in step response = self.llm.completion(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 478, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/llm/llm.py", line 241, in wrapper resp: ModelResponse = self._completion_unwrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1235, in wrapper raise e File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1113, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 3137, in completion raise exception_type( ^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2214, in exception_type raise e File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2183, in exception_type raise APIConnectionError( litellm.exceptions.APIConnectionError: litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused

INFO: 172.17.0.1:60452 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/list-files HTTP/1.1" 200 OK 18:04:54 - openhands:WARNING: agent_controller.py:280 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Unknown exception type while running the agent: APIConnectionError. 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.ERROR 18:04:54 - openhands:INFO: session.py:259 - Agent status error 18:04:54 - openhands:INFO: session.py:200 - Agent status error 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='error', observation='agent_state_changed') 18:05:03 - openhands:INFO: standalone_conversation_manager.py:351 - _close_session:bb3ad225587d424887cda0d60ea654e2 18:05:03 - openhands:INFO: standalone_conversation_manager.py:359 - removing connections: [] 18:05:03 - openhands:INFO: standalone_conversation_manager.py:371 - closing_session:bb3ad225587d424887cda0d60ea654e2 18:05:03 - openhands:INFO: agent_controller.py:520 - [Agent Controller bb3ad225587d424887cda0d60ea654e2] Setting agent(CodeActAgent) state from AgentState.AWAITING_USER_INPUT to AgentState.STOPPED 18:05:03 - openhands:WARNING: stream.py:260 - Callback not found during unsubscribe: bb3ad225587d424887cda0d60ea654e2 18:05:05 - openhands:INFO: standalone_conversation_manager.py:373 - closed_session:bb3ad225587d424887cda0d60ea654e2 18:05:07 - USER_ACTION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] MessageAction (source=EventSource.USER) CONTENT: test 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.RUNNING 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='running', observation='agent_state_changed') 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] NullObservation(content='', observation='null')

============== [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] LEVEL 0 LOCAL STEP 1 GLOBAL STEP 1

18:05:07 - openhands:ERROR: agent_controller.py:260 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Error while running the agent (session ID: 514f3449c5544bc7a724d6e6fda02aa6): litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused. Traceback: Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 250, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request raise exc from None File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request response = connection.handle_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 101, in handle_request raise exc File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 78, in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 124, in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp with map_exceptions(exc_map): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ConnectError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 118, in _make_common_sync_call response = sync_httpx_client.post( ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 559, in post raise e File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 537, in post response = self.client.send(req, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1014, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 249, in handle_request with map_httpcore_exceptions(): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/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

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 2825, in completion response = base_llm_http_handler.completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 377, in completion response = self._make_common_sync_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 141, in _make_common_sync_call raise self._handle_error(e=e, provider_config=provider_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 1209, in _handle_error raise provider_config.get_error_class( litellm.llms.ollama.common_utils.OllamaError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/openhands/controller/agent_controller.py", line 258, in _step_with_exception_handling await self._step() File "/app/openhands/controller/agent_controller.py", line 732, in _step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 122, in step response = self.llm.completion(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 478, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/llm/llm.py", line 241, in wrapper resp: ModelResponse = self._completion_unwrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1235, in wrapper raise e File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1113, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 3137, in completion raise exception_type( ^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2214, in exception_type raise e File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2183, in exception_type raise APIConnectionError( litellm.exceptions.APIConnectionError: litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused

18:05:07 - openhands:WARNING: agent_controller.py:280 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Unknown exception type while running the agent: APIConnectionError. 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.ERROR 18:05:07 - openhands:INFO: session.py:259 - Agent status error 18:05:07 - openhands:INFO: session.py:200 - Agent status error 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='error', observation='agent_state_changed') 18:05:07 - openhands:INFO: standalone_conversation_manager.py:102 - Conversation 514f3449c5544bc7a724d6e6fda02aa6 connected in 0.0178678035736084 seconds 18:05:07 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:49030 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/web-hosts HTTP/1.1" 200 OK INFO: 172.17.0.1:49038 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/list-files HTTP/1.1" 200 OK`

OpenHands Installation

Docker command in README

OpenHands Version

No response

Operating System

None

Logs, Errors, Screenshots, and Additional Context

`root@DESKTOP-NK2R4R0:~# docker run -it --rm --pull=always -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik -e LOG_ALL_EVENTS=true -v /var/run/docker.sock:/var/run/docker.sock -v ~/.openhands-state:/.openhands-state -p 3000:3000 --add-host host.docker.internal:host-gateway -e LLM_OLLAMA_BASE_URL="http://host.docker.internal:11434" --name openhands-app docker.all-hands.dev/all-hands-ai/openhands:0.29 0.29: Pulling from all-hands-ai/openhands Digest: sha256:17048b1c9c16574550698020f90371520ae73f5e6b1a2920d04d0e3f8615a8c1 Status: Image is up to date for docker.all-hands.dev/all-hands-ai/openhands:0.29 Starting OpenHands... Running OpenHands as root 18:04:02 - openhands:INFO: server_config.py:38 - Using config class None INFO: Started server process [10] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:3000 (Press CTRL+C to quit) INFO: 172.17.0.1:49884 - "GET /conversations/bb3ad225587d424887cda0d60ea654e2 HTTP/1.1" 200 OK INFO: 172.17.0.1:49884 - "GET /locales/en/translation.json HTTP/1.1" 200 OK INFO: 172.17.0.1:49884 - "GET /api/options/config HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/settings HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /favicon.ico HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/conversations/bb3ad225587d424887cda0d60ea654e2 HTTP/1.1" 200 OK INFO: ('172.17.0.1', 49904) - "WebSocket /socket.io/?latest_event_id=-1&conversation_id=bb3ad225587d424887cda0d60ea654e2&EIO=4&transport=websocket" [accepted] 18:04:06 - openhands:INFO: listen_socket.py:32 - sio:connect: sT35AT7tokp34CD4AAAB 18:04:06 - openhands:INFO: standalone_conversation_manager.py:116 - join_conversation:bb3ad225587d424887cda0d60ea654e2:sT35AT7tokp34CD4AAAB 18:04:06 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:259 - maybe_start_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:262 - start_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:bb3ad225587d424887cda0d60ea654e2 18:04:06 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:bb3ad225587d424887cda0d60ea654e2 18:04:07 - openhands:INFO: docker_runtime.py:140 - [runtime bb3ad225587d424887cda0d60ea654e2] Starting runtime with image: docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik 18:04:07 - openhands:INFO: listen_socket.py:81 - sio:disconnect:sT35AT7tokp34CD4AAAB 18:04:07 - openhands:INFO: standalone_conversation_manager.py:334 - disconnect_from_session:sT35AT7tokp34CD4AAAB:bb3ad225587d424887cda0d60ea654e2 18:04:07 - openhands:ERROR: public.py:70 - Error getting OLLAMA models: HTTPConnectionPool(host='host.docker.internal', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f55e2a0e060>: Failed to establish a new connection: [Errno 111] Connection refused')) INFO: 172.17.0.1:49898 - "GET /api/options/models HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/options/agents HTTP/1.1" 200 OK INFO: 172.17.0.1:49898 - "GET /api/options/security-analyzers HTTP/1.1" 200 OK 18:04:08 - openhands:INFO: docker_runtime.py:144 - [runtime bb3ad225587d424887cda0d60ea654e2] Container started: openhands-runtime-bb3ad225587d424887cda0d60ea654e2. VSCode URL: None 18:04:08 - openhands:INFO: docker_runtime.py:155 - [runtime bb3ad225587d424887cda0d60ea654e2] Waiting for client to become ready at http://host.docker.internal:37649... 18:04:26 - openhands:INFO: manage_conversations.py:148 - Initializing new conversation 18:04:26 - openhands:INFO: manage_conversations.py:54 - Creating conversation 18:04:26 - openhands:INFO: manage_conversations.py:58 - Loading settings 18:04:26 - openhands:INFO: manage_conversations.py:61 - Settings loaded 18:04:26 - openhands:INFO: manage_conversations.py:85 - Loading conversation store 18:04:26 - openhands:INFO: manage_conversations.py:87 - Conversation store loaded 18:04:26 - openhands:INFO: manage_conversations.py:93 - New conversation ID: 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:103 - Saving metadata for conversation 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:115 - Starting agent loop for conversation 514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:259 - maybe_start_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:262 - start_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: manage_conversations.py:136 - Finished initializing conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:54154 - "POST /api/conversations HTTP/1.1" 200 OK INFO: ('172.17.0.1', 54164) - "WebSocket /socket.io/?latest_event_id=-1&conversation_id=514f3449c5544bc7a724d6e6fda02aa6&EIO=4&transport=websocket" [accepted] INFO: 172.17.0.1:54154 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6 HTTP/1.1" 200 OK 18:04:26 - openhands:INFO: listen_socket.py:32 - sio:connect: aQQ3ZEj-0AQ-vh8UAAAD 18:04:26 - openhands:INFO: standalone_conversation_manager.py:116 - join_conversation:514f3449c5544bc7a724d6e6fda02aa6:aQQ3ZEj-0AQ-vh8UAAAD 18:04:26 - openhands:INFO: standalone_conversation_manager.py:312 - _get_event_stream:514f3449c5544bc7a724d6e6fda02aa6 18:04:26 - openhands:INFO: standalone_conversation_manager.py:315 - found_local_agent_loop:514f3449c5544bc7a724d6e6fda02aa6 18:04:27 - openhands:INFO: docker_runtime.py:140 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Starting runtime with image: docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik 18:04:28 - openhands:INFO: docker_runtime.py:144 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Container started: openhands-runtime-514f3449c5544bc7a724d6e6fda02aa6. VSCode URL: None 18:04:28 - openhands:INFO: docker_runtime.py:155 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Waiting for client to become ready at http://host.docker.internal:38256... 18:04:34 - openhands:INFO: docker_runtime.py:161 - [runtime bb3ad225587d424887cda0d60ea654e2] Runtime is ready. 18:04:34 - openhands:INFO: base.py:346 - [runtime bb3ad225587d424887cda0d60ea654e2] Selected repo: None, loading microagents from /workspace/.openhands/microagents (inside runtime) 18:04:34 - openhands:INFO: memory.py:233 - Loading user workspace microagents: [] 18:04:34 - openhands:INFO: agent_session.py:161 - Agent session start 18:04:34 - openhands:INFO: agent_controller.py:520 - [Agent Controller bb3ad225587d424887cda0d60ea654e2] Setting agent(CodeActAgent) state from AgentState.LOADING to AgentState.AWAITING_USER_INPUT 18:04:34 - OBSERVATION [Agent Controller bb3ad225587d424887cda0d60ea654e2] AgentStateChangedObservation(content='', agent_state='awaiting_user_input', observation='agent_state_changed') 18:04:54 - openhands:INFO: docker_runtime.py:161 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Runtime is ready. 18:04:54 - openhands:INFO: base.py:346 - [runtime 514f3449c5544bc7a724d6e6fda02aa6] Selected repo: None, loading microagents from /workspace/.openhands/microagents (inside runtime) 18:04:54 - openhands:INFO: memory.py:233 - Loading user workspace microagents: [] 18:04:54 - openhands:INFO: agent_session.py:161 - Agent session start 18:04:54 - USER_ACTION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] MessageAction (source=EventSource.USER) CONTENT: test 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.LOADING to AgentState.RUNNING 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.RUNNING 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='running', observation='agent_state_changed') 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] RecallObservation recall_type=RecallType.WORKSPACE_CONTEXT, repo_name=, repo_instructions=..., runtime_hosts={'http://localhost:50727': 50727, 'http://localhost:57045': 57045}, additional_agent_instructions=...

============== [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] LEVEL 0 LOCAL STEP 0 GLOBAL STEP 0

18:04:54 - openhands:INFO: standalone_conversation_manager.py:102 - Conversation 514f3449c5544bc7a724d6e6fda02aa6 connected in 0.03493046760559082 seconds 18:04:54 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:60456 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/web-hosts HTTP/1.1" 200 OK 18:04:54 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:60468 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/vscode-url HTTP/1.1" 200 OK 18:04:54 - openhands:ERROR: agent_controller.py:260 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Error while running the agent (session ID: 514f3449c5544bc7a724d6e6fda02aa6): litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused. Traceback: Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 250, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request raise exc from None File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request response = connection.handle_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 101, in handle_request raise exc File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 78, in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 124, in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp with map_exceptions(exc_map): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ConnectError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 118, in _make_common_sync_call response = sync_httpx_client.post( ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 559, in post raise e File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 537, in post response = self.client.send(req, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1014, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 249, in handle_request with map_httpcore_exceptions(): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/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

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 2825, in completion response = base_llm_http_handler.completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 377, in completion response = self._make_common_sync_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 141, in _make_common_sync_call raise self._handle_error(e=e, provider_config=provider_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 1209, in _handle_error raise provider_config.get_error_class( litellm.llms.ollama.common_utils.OllamaError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/openhands/controller/agent_controller.py", line 258, in _step_with_exception_handling await self._step() File "/app/openhands/controller/agent_controller.py", line 732, in _step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 122, in step response = self.llm.completion(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 478, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/llm/llm.py", line 241, in wrapper resp: ModelResponse = self._completion_unwrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1235, in wrapper raise e File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1113, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 3137, in completion raise exception_type( ^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2214, in exception_type raise e File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2183, in exception_type raise APIConnectionError( litellm.exceptions.APIConnectionError: litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused

INFO: 172.17.0.1:60452 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/list-files HTTP/1.1" 200 OK 18:04:54 - openhands:WARNING: agent_controller.py:280 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Unknown exception type while running the agent: APIConnectionError. 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR 18:04:54 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.ERROR 18:04:54 - openhands:INFO: session.py:259 - Agent status error 18:04:54 - openhands:INFO: session.py:200 - Agent status error 18:04:54 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='error', observation='agent_state_changed') 18:05:03 - openhands:INFO: standalone_conversation_manager.py:351 - _close_session:bb3ad225587d424887cda0d60ea654e2 18:05:03 - openhands:INFO: standalone_conversation_manager.py:359 - removing connections: [] 18:05:03 - openhands:INFO: standalone_conversation_manager.py:371 - closing_session:bb3ad225587d424887cda0d60ea654e2 18:05:03 - openhands:INFO: agent_controller.py:520 - [Agent Controller bb3ad225587d424887cda0d60ea654e2] Setting agent(CodeActAgent) state from AgentState.AWAITING_USER_INPUT to AgentState.STOPPED 18:05:03 - openhands:WARNING: stream.py:260 - Callback not found during unsubscribe: bb3ad225587d424887cda0d60ea654e2 18:05:05 - openhands:INFO: standalone_conversation_manager.py:373 - closed_session:bb3ad225587d424887cda0d60ea654e2 18:05:07 - USER_ACTION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] MessageAction (source=EventSource.USER) CONTENT: test 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.RUNNING 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='running', observation='agent_state_changed') 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] NullObservation(content='', observation='null')

============== [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] LEVEL 0 LOCAL STEP 1 GLOBAL STEP 1

18:05:07 - openhands:ERROR: agent_controller.py:260 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Error while running the agent (session ID: 514f3449c5544bc7a724d6e6fda02aa6): litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused. Traceback: Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 250, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request raise exc from None File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request response = connection.handle_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 101, in handle_request raise exc File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 78, in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 124, in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp with map_exceptions(exc_map): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ConnectError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 118, in _make_common_sync_call response = sync_httpx_client.post( ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 559, in post raise e File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 537, in post response = self.client.send(req, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1014, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 249, in handle_request with map_httpcore_exceptions(): File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/app/.venv/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

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 2825, in completion response = base_llm_http_handler.completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 377, in completion response = self._make_common_sync_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 141, in _make_common_sync_call raise self._handle_error(e=e, provider_config=provider_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 1209, in _handle_error raise provider_config.get_error_class( litellm.llms.ollama.common_utils.OllamaError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/openhands/controller/agent_controller.py", line 258, in _step_with_exception_handling await self._step() File "/app/openhands/controller/agent_controller.py", line 732, in _step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 122, in step response = self.llm.completion(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 478, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/app/openhands/llm/llm.py", line 241, in wrapper resp: ModelResponse = self._completion_unwrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1235, in wrapper raise e File "/app/.venv/lib/python3.12/site-packages/litellm/utils.py", line 1113, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/main.py", line 3137, in completion raise exception_type( ^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2214, in exception_type raise e File "/app/.venv/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2183, in exception_type raise APIConnectionError( litellm.exceptions.APIConnectionError: litellm.APIConnectionError: OllamaException - [Errno 111] Connection refused

18:05:07 - openhands:WARNING: agent_controller.py:280 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Unknown exception type while running the agent: APIConnectionError. 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR 18:05:07 - openhands:INFO: agent_controller.py:520 - [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.ERROR 18:05:07 - openhands:INFO: session.py:259 - Agent status error 18:05:07 - openhands:INFO: session.py:200 - Agent status error 18:05:07 - OBSERVATION [Agent Controller 514f3449c5544bc7a724d6e6fda02aa6] AgentStateChangedObservation(content='', agent_state='error', observation='agent_state_changed') 18:05:07 - openhands:INFO: standalone_conversation_manager.py:102 - Conversation 514f3449c5544bc7a724d6e6fda02aa6 connected in 0.0178678035736084 seconds 18:05:07 - openhands:INFO: standalone_conversation_manager.py:76 - Reusing active conversation 514f3449c5544bc7a724d6e6fda02aa6 INFO: 172.17.0.1:49030 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/web-hosts HTTP/1.1" 200 OK INFO: 172.17.0.1:49038 - "GET /api/conversations/514f3449c5544bc7a724d6e6fda02aa6/list-files HTTP/1.1" 200 OK`

namen3645 avatar Mar 25 '25 18:03 namen3645

try LLM_OLLAMA_BASE_URL as http://172.17.0.1:11434

YealKio avatar Mar 29 '25 04:03 YealKio

or LLM_OLLAMA_BASE_URL as http://127.0.0.1:11434

blakkd avatar Apr 05 '25 02:04 blakkd

Is this still happening? The log shows it's not connecting from the docker container to Ollama. You may need to configure Ollama to be accessible, for that set in the environment:

OLLAMA_HOST=0.0.0.0:11434
OLLAMA_ORIGINS=*

I think LLM_OLLAMA_BASE_URL is used for getting a list of models, not for connection.

enyst avatar Apr 05 '25 07:04 enyst

I personally got mad for almost a hour before trying this and inference seems to use this variable too

blakkd avatar Apr 05 '25 18:04 blakkd

If it works for you, that's great @blakkd , thank you!

It may have been a different issue than the OP.

enyst avatar Apr 05 '25 19:04 enyst

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 05 '25 02:06 github-actions[bot]

This issue was closed because it has been stalled for over 30 days with no activity.

github-actions[bot] avatar Jun 12 '25 02:06 github-actions[bot]