# Can't connect to Weviate Client in using helper function in Container

**URL:** https://forum.weaviate.io/t/cant-connect-to-weviate-client-in-using-helper-function-in-container/9581
**Category:** Support
**Created:** [January 6, 2025, 2:34pm UTC](https://forum.weaviate.io/t/cant-connect-to-weviate-client-in-using-helper-function-in-container/9581 "2025-01-06T14:34:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rishav\_Kumar\_Paramha](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/rishav_kumar_paramha/32/3295_2.png) [@Rishav\_Kumar\_Paramha](https://forum.weaviate.io/u/Rishav_Kumar_Paramha)
#### Post date: [January 6, 2025, 2:34pm UTC](https://forum.weaviate.io/t/cant-connect-to-weviate-client-in-using-helper-function-in-container/9581/1 "2025-01-06T14:34:02Z")

</div>

### Description

Hi All, I have create a docker image for Weaviate using the docker compose file:

```yaml
---
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: cr.weaviate.io/semitechnologies/weaviate:1.27.8
    ports:
    - 8080:8080
    - 50051:50051
    volumes:
    - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    environment:
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      ENABLE_API_BASED_MODULES: 'true'
      CLUSTER_HOSTNAME: 'node1'
volumes:
  weaviate_data:
...

```

and trying to connect to the Wevaite client like this:

```python
# Now use the host, port, and grpc_port in the connection
client = weaviate.connect_to_local(
    host="127.0.0.1", # Use a string to specify the host
    port=8080,
    grpc_port=50051,
)

```

It works absolutely fine when i have Weaviate container running on my local machine using Docker desktop and a script to connect to the instance. But as soon as i try to connect to the Weaviate container from another container - it always ends up with this error:  
2025-01-04 15:02:30 Traceback (most recent call last):  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_transports/default.py”, line 69, in map\_httpcore\_exceptions  
2025-01-04 15:02:30 yield  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_transports/default.py”, line 373, in handle\_async\_request  
2025-01-04 15:02:30 resp = await self.\_pool.handle\_async\_request(req)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_async/connection\_pool.py”, line 256, in handle\_async\_request  
2025-01-04 15:02:30 raise exc from None  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_async/connection\_pool.py”, line 236, in handle\_async\_request  
2025-01-04 15:02:30 response = await connection.handle\_async\_request(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_async/connection.py”, line 101, in handle\_async\_request  
2025-01-04 15:02:30 raise exc  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_async/connection.py”, line 78, in handle\_async\_request  
2025-01-04 15:02:30 stream = await self.\_connect(request)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_async/connection.py”, line 124, in \_connect  
2025-01-04 15:02:30 stream = await self.\_network\_backend.connect\_tcp(\*\*kwargs)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_backends/auto.py”, line 31, in connect\_tcp  
2025-01-04 15:02:30 return await self.\_backend.connect\_tcp(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_backends/anyio.py”, line 113, in connect\_tcp  
2025-01-04 15:02:30 with map\_exceptions(exc\_map):  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/contextlib.py”, line 158, in **exit**  
2025-01-04 15:02:30 self.gen.throw(value)  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpcore/\_exceptions.py”, line 14, in map\_exceptions  
2025-01-04 15:02:30 raise to\_exc(exc) from exc  
2025-01-04 15:02:30 httpcore.ConnectError: All connection attempts failed  
2025-01-04 15:02:30  
2025-01-04 15:02:30 The above exception was the direct cause of the following exception:  
2025-01-04 15:02:30  
2025-01-04 15:02:30 Traceback (most recent call last):  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/v4.py”, line 264, in \_open\_connections\_rest  
2025-01-04 15:02:30 response = await client.get(oidc\_url)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1801, in get  
2025-01-04 15:02:30 return await self.request(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1574, in request  
2025-01-04 15:02:30 return await self.send(request, auth=auth, follow\_redirects=follow\_redirects)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1661, in send  
2025-01-04 15:02:30 response = await self.\_send\_handling\_auth(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1689, in \_send\_handling\_auth  
2025-01-04 15:02:30 response = await self.\_send\_handling\_redirects(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1726, in \_send\_handling\_redirects  
2025-01-04 15:02:30 response = await self.\_send\_single\_request(request)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_client.py”, line 1763, in \_send\_single\_request  
2025-01-04 15:02:30 response = await transport.handle\_async\_request(request)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_transports/default.py”, line 372, in handle\_async\_request  
2025-01-04 15:02:30 with map\_httpcore\_exceptions():  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/contextlib.py”, line 158, in **exit**  
2025-01-04 15:02:30 self.gen.throw(value)  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/httpx/\_transports/default.py”, line 86, in map\_httpcore\_exceptions  
2025-01-04 15:02:30 raise mapped\_exc(message) from exc  
2025-01-04 15:02:30 httpx.ConnectError: All connection attempts failed  
2025-01-04 15:02:30  
2025-01-04 15:02:30 During handling of the above exception, another exception occurred:  
2025-01-04 15:02:30  
2025-01-04 15:02:30 Traceback (most recent call last):  
2025-01-04 15:02:30 File “/usr/local/bin/uvicorn”, line 8, in   
2025-01-04 15:02:30 sys.exit(main())  
2025-01-04 15:02:30 ^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/click/core.py”, line 1157, in **call**  
2025-01-04 15:02:30 return self.main(\*args, \*\*kwargs)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/click/core.py”, line 1078, in main  
2025-01-04 15:02:30 rv = self.invoke(ctx)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/click/core.py”, line 1434, in invoke  
2025-01-04 15:02:30 return ctx.invoke(self.callback, \*\*ctx.params)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/click/core.py”, line 783, in invoke  
2025-01-04 15:02:30 return \_\_callback(\*args, \*\*kwargs)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/main.py”, line 416, in main  
2025-01-04 15:02:30 run(  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/main.py”, line 587, in run  
2025-01-04 15:02:30 server.run()  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/server.py”, line 61, in run  
2025-01-04 15:02:30 return asyncio.run(self.serve(sockets=sockets))  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/asyncio/runners.py”, line 194, in run  
2025-01-04 15:02:30 return runner.run(main)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/asyncio/runners.py”, line 118, in run  
2025-01-04 15:02:30 return self.\_loop.run\_until\_complete(task)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “uvloop/loop.pyx”, line 1518, in uvloop.loop.Loop.run\_until\_complete  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/server.py”, line 68, in serve  
2025-01-04 15:02:30 config.load()  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/config.py”, line 467, in load  
2025-01-04 15:02:30 self.loaded\_app = import\_from\_string(self.app)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/uvicorn/importer.py”, line 21, in import\_from\_string  
2025-01-04 15:02:30 module = importlib.import\_module(module\_str)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/importlib/ **init**.py”, line 90, in import\_module  
2025-01-04 15:02:30 return \_bootstrap.\_gcd\_import(name[level:], package, level)  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “”, line 1387, in \_gcd\_import  
2025-01-04 15:02:30 File “”, line 1360, in \_find\_and\_load  
2025-01-04 15:02:30 File “”, line 1331, in \_find\_and\_load\_unlocked  
2025-01-04 15:02:30 File “”, line 935, in \_load\_unlocked  
2025-01-04 15:02:30 File “”, line 999, in exec\_module  
2025-01-04 15:02:30 File “”, line 488, in \_call\_with\_frames\_removed  
2025-01-04 15:02:30 File “/PrivatAI-backend/backend.py”, line 63, in   
2025-01-04 15:02:30 client = weaviate.connect\_to\_local(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 210, in connect\_to\_local  
2025-01-04 15:02:30 return \_\_connect(  
2025-01-04 15:02:30 ^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 411, in \_\_connect  
2025-01-04 15:02:30 raise e  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 407, in \_\_connect  
2025-01-04 15:02:30 client.connect()  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/syncify.py”, line 23, in sync\_method  
2025-01-04 15:02:30 return \_EventLoopSingleton.get\_instance().run\_until\_complete(  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/event\_loop.py”, line 42, in run\_until\_complete  
2025-01-04 15:02:30 return fut.result()  
2025-01-04 15:02:30 ^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/concurrent/futures/\_base.py”, line 456, in result  
2025-01-04 15:02:30 return self.\_\_get\_result()  
2025-01-04 15:02:30 ^^^^^^^^^^^^^^^^^^^  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/concurrent/futures/\_base.py”, line 401, in \_\_get\_result  
2025-01-04 15:02:30 raise self.\_exception  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/client\_base.py”, line 153, in connect  
2025-01-04 15:02:30 await self.\_connection.connect(self.\_skip\_init\_checks)  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/v4.py”, line 154, in connect  
2025-01-04 15:02:30 await self.\_open\_connections\_rest(self.\_auth, skip\_init\_checks)  
2025-01-04 15:02:30 File “/usr/local/lib/python3.12/site-packages/weaviate/connect/v4.py”, line 266, in \_open\_connections\_rest  
2025-01-04 15:02:30 raise WeaviateConnectionError(  
2025-01-04 15:02:30 weaviate.exceptions.WeaviateConnectionError: Connection to Weaviate failed. Details: Error: All connection attempts failed.  
2025-01-04 15:02:30 Is Weaviate running and reachable at [http://127.0.0.1:8080](http://127.0.0.1:8080)?

- Weaviate Server Version:
- Deployment Method: connect to local\>
- Multi Node? Number of Running Nodes:
- Client Language and Version: I am using Python Client v4

### Any additional Information

I tried it both as conatinerized code on my local machine using Docker desktop also on AWS EC2 instance running this docker containers using the Public IPs as host. Note: When i try to directly connect to wevaite using [http://host](http://host):port-- i always see the reponse, so i know that the port 8080 is open an accessible

Can you please help me as soon as possible.. I am stuck on this from past two days and find no way to solve this.

Thanks

Regards  
Rishav

---

<div class="post-metadata">

### Author: ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)
#### Post date: [January 6, 2025, 6:09pm UTC](https://forum.weaviate.io/t/cant-connect-to-weviate-client-in-using-helper-function-in-container/9581/2 "2025-01-06T18:09:06Z")

</div>

hi @Rishav_Kumar_Paramha

Welcome to our community 🤗

From what you are describing, indeed Weaviate should be available.

Are you running the python code from your computer, or from within a second container?

Feel free to reach out to me in our public slack so I can take a closer look. By experience, this kind of issues are better solved with a quick screen sharing session.

Thanks!
