[Question] gRPC Connection Issues in Weaviate v4 (Hybrid Search & fetch_by_object_id Failing)

I’m using Weaviate v4 to create a collection and index data. However, when I try to search the indexed data, both multi target vector search and fetch_by_object_id fail with a gRPC-related error.
Could you help me figure out where the issue is?

My Weaviate instance is running via Docker Compose, and I’m using Weaviate version 1.29.0 (also tested with 1.27.0, same issue).

Env

image: cr.weaviate.io/semitechnologies/weaviate:1.29.0
weaivate python client: 4.11.0
python 3.10.12

Error Message

Query call with protocol GRPC search failed with message The request to Weaviate failed after 5 retries. Details: <AioRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:115.x.x.x:50054: Failed to connect to remote host: connect: Connection refused (111)"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2025-02-26T06:45:13.059068484+00:00", grpc_status:14, grpc_message:"failed to connect to all addresses; last error: UNKNOWN: ipv4:115.x.x.x:50054: Failed to connect to remote host: connect: Connection refused (111)"}" 

Setup Details

services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8083'
    - --scheme
    - http
    image: cr.weaviate.io/semitechnologies/weaviate:1.29.0
    ports:
    - 8083:8083
    - 50054:50054
    ipc: host
    volumes:
    - ./weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    environment:
      ASYNC_INDEXING: 'true'
      DISABLE_TEMETRY: 'true'
      LOG_LEVEL: 'debug'
      QUERY_DEFAULTS_LIMIT: 100
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      DISK_USE_WARNING_PERCENTAGE: 80
      DISK_USE_READONLY_PERCENTAGE: 95
      MEMORY_READONLY_PERCENTAGE: 95
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      DEFAULT_VECTORIZER_MODULE: 'none'
      ENABLE_MODULES: ''
      CLUSTER_HOSTNAME: 'node1'
      GOMAXPROCS: 48

Python Create and Insert Code

import os 
import re
from weaviate.classes.query import MetadataQuery
import weaviate
from weaviate.connect import ConnectionParams
from weaviate.classes.init import AdditionalConfig, Timeout, Auth
from weaviate.classes.config import Configure, Property, DataType, VectorDistances, VectorFilterStrategy
from weaviate.classes.query import HybridFusion
from weaviate.classes.query import TargetVectors, MetadataQuery
from auto_encoder import auto_encoder
from tqdm import tqdm 

"""Collection creation code (multiple target vectors)"""
vdb_grpc_host = 'localhost'
vdb_http_port = '8083'
vdb_http_host = 'localhost'
vdb_grpc_port = '50054'

connection_params = ConnectionParams.from_params(
    http_host=vdb_http_host,
    http_port=vdb_http_port,
    grpc_host=vdb_grpc_host,
    grpc_port=vdb_grpc_port,
    http_secure=False,
    grpc_secure=False,
)
additional_config = AdditionalConfig(
    timeout=Timeout(init=30, query=60, insert=120), 
)

connection = weaviate.WeaviateClient(
    connection_params=connection_params,
    additional_config=additional_config,
    skip_init_checks=True
)

connection.connect()
COLLECTION_ID = 'Test'
res = connection.collections.create(
    COLLECTION_ID,
    vectorizer_config=[
        Configure.NamedVectors.none(name="name", vector_index_config=Configure.VectorIndex.hnsw()),
        Configure.NamedVectors.none(name="content", vector_index_config=Configure.VectorIndex.hnsw()),
    ]
)

"""Collection data indexing code"""
data = {
    "name": "sample name",
    "content": "blahblah",
    "length": 435
}

vector = {
    'name': name_v, 
    'content': content_v
}

target_collection = connection.collections.get(COLLECTION_ID)
uuid = target_collection.data.insert(
    properties=data,
    vector=vector
)
print(uuid)  # > UUID('d15dc94b-efe4-4e92-8e69-0af29c6f6755')

python search Code

collection = connection.collections.get(COLLECTION_ID)
print("----collection-----")
print(collection)

text_list = ["name_test", "content_v"]
name_v, content_v = auto_encoder.local_embedding(text_list, ENCODER_ID)
print(len(name_v))  # > 4096

try:
    vector_map = {
        "name": name_v,
        "content": content_v
    }

    response = collection.query.near_vector(
        near_vector=vector_map,
        target_vector=["name", "content"],
        return_metadata=MetadataQuery(distance=True)
    )

    print("====response====")
    for o in response.objects:
        print(o.properties)
        print(o.metadata.distance)
except Exception as e:
    print(str(e))
finally:
    connection.close()

Hey, you need to set the GRPC_PORT environment variable.

2 Likes