Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to host #43

Open
sindastra opened this issue Apr 15, 2024 · 5 comments
Open

Cannot connect to host #43

sindastra opened this issue Apr 15, 2024 · 5 comments

Comments

@sindastra
Copy link

Hi, I configured the bot to connect to 172.17.0.1:11434 but I got an error message that it could not connect.

If I run curl 172.17.0.1:11434 I get Ollama is running, so I know the server is up and running and reachable. I also know the firewall is set up properly because other Docker images can access Ollama just fine.

Here's the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 651, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 691, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('172.17.0.1', 11434)

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

Traceback (most recent call last):
  File "/code/run.py", line 194, in ollama_request
    async for response_data in generate(payload, modelname, prompt):
  File "/code/func/functions.py", line 49, in generate
    async with session.post(url, json=payload) as response:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 172.17.0.1:11434 ssl:default [Connect call failed ('172.17.0.1', 11434)]
@alejandrogomezdp
Copy link

Any comments on how to resolve this issue?

@CRASH-Tech
Copy link

Same issue

@ruecat
Copy link
Owner

ruecat commented May 18, 2024

You should use your container name, not the ip.

@sindastra
Copy link
Author

sindastra commented May 18, 2024

@ruecat

You should use your container name, not the ip.

Ollama is running on the host, not in a container.

@cucumberian
Copy link

@ruecat

You should use your container name, not the ip.

Ollama is running on the host, not in a container.

for ollama on host use host for network_mode in container:

# docker-compose sample
version: "3"

services:
  bot:
    build:
      context: ./
    network_mode: "host"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants