Not able to connect to weaviate using local instance

Hello,
I am trying to connect to weaviate using loca_instance below is my code snippet:

self.client = weaviate.connect_to_local(
                host="0.0.0.0",  # Use a string to specify the host
                port=8080,
                grpc_port=50051,
                headers=headers,
                auth_credentials=AuthApiKey(weaviate_api_key)
            )

I am running it using docker, my docker compose is as below:

eaviate:
    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
    env_file: .env
    healthcheck:
      test: wget --no-verbose --tries=3 --spider http://localhost:8080/v1/.well-known/ready || exit 1
      interval: 5s
      timeout: 10s
      retries: 5
      start_period: 10s

I am getting below error for connecting to weaviate

Traceback (most recent call last):
File β€œ/usr/local/lib/python3.12/site-packages/starlette/routing.py”, line 693, in lifespan
async with self.lifespan_context(app) as maybe_state:
^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/usr/local/lib/python3.12/contextlib.py”, line 210, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File β€œ/app/app.py”, line 57, in lifespan
await weaviate_app.setup()
File β€œ/app/weaviate_manager/manager.py”, line 51, in setup
self.client = weaviate.connect_to_local(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 210, in connect_to_local
return __connect(
^^^^^^^^^^
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 411, in __connect
raise e
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/connect/helpers.py”, line 407, in __connect
client.connect()
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/syncify.py”, line 23, in sync_method
return _EventLoopSingleton.get_instance().run_until_complete(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/event_loop.py”, line 42, in run_until_complete
return fut.result()
^^^^^^^^^^^^
File β€œ/usr/local/lib/python3.12/concurrent/futures/_base.py”, line 456, 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 β€œ/usr/local/lib/python3.12/site-packages/weaviate/client_base.py”, line 153, in connect
await self._connection.connect(self._skip_init_checks)
File β€œ/usr/local/lib/python3.12/site-packages/weaviate/connect/v4.py”, line 177, in connect
raise WeaviateStartUpError(f"Could not connect to Weaviate:{e}.") from e
weaviate.exceptions.WeaviateStartUpError: Could not connect to Weaviate:Connection to Weaviate failed. Details: .

when I checked logs for container, I understood that my weaviate is running but not able to connect.

can u pl check the issue.
Am I missing anything or doing wrong ?

Hey @Rohini_vaidya,

As we discussed during the community office hour, please make sure to configure your Docker Compose with like this at the top of your conatiners:

networks:
  example_network:
    driver: bridge

Then, in each container configuration, add:

networks:
  - example_network

After that, re-run your containers for the API app and any other services you’re using β€” everything should work fine.

Let me know if that solves the issue


1 Like