Description
Hi All, I have create a docker image for Weaviate using the docker compose file:
---
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:
# 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?
- 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: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