High severity intermediate · Fix: 5-10 min

ConnectionRefusedError

weaviate.exceptions.ConnectionRefusedError

What this error means
The Weaviate client fails to connect to the Weaviate server due to refused connection or schema mismatch errors during RAG vector store initialization.

Stack trace

traceback
weaviate.exceptions.ConnectionRefusedError: Failed to connect to Weaviate server at 'http://localhost:8080'. Connection refused.
During schema validation: Schema mismatch or missing class detected.
QUICK FIX
Verify Weaviate server is running and reachable at the correct endpoint URL before initializing the client.

Why it happens

This error occurs when the Weaviate client cannot establish a network connection to the Weaviate server, often because the server is down, the endpoint URL is incorrect, or firewall rules block access. Additionally, if the expected schema class is missing or mismatched, the client raises an error during schema validation.

Detection

Monitor connection attempts to the Weaviate endpoint and catch ConnectionRefusedError exceptions. Log schema validation steps to detect missing or incorrect schema classes before runtime failures.

Causes & fixes

1

Weaviate server is not running or unreachable at the specified endpoint.

✓ Fix

Start the Weaviate server and verify the endpoint URL and port are correct and accessible from your client environment.

2

Incorrect or missing schema class in Weaviate database for your RAG vector store.

✓ Fix

Define and apply the correct schema class in Weaviate matching your vector store requirements before connecting.

3

Network firewall or proxy blocking connection to Weaviate server.

✓ Fix

Configure firewall or proxy settings to allow traffic on the Weaviate server port (default 8080).

4

Using HTTP instead of HTTPS or vice versa causing connection refusal.

✓ Fix

Ensure the protocol in the endpoint URL matches the Weaviate server configuration (http:// or https://).

Code: broken vs fixed

Broken - triggers the error
python
import weaviate

client = weaviate.Client(url='http://localhost:8080')

# This line triggers connection refused error if server is down
schema = client.schema.get()
Fixed - works correctly
python
import os
import weaviate

WEAVIATE_URL = os.environ.get('WEAVIATE_URL', 'http://localhost:8080')
client = weaviate.Client(url=WEAVIATE_URL)  # Use env var for flexibility

# Confirm connection before schema call
try:
    schema = client.schema.get()
    print('Connected and schema retrieved successfully')
except weaviate.exceptions.ConnectionRefusedError as e:
    print(f'Connection failed: {e}')
    # Handle or retry connection here
Added environment variable for endpoint URL and wrapped schema call in try/except to handle connection refused errors gracefully.

Workaround

Catch ConnectionRefusedError and implement a retry loop with exponential backoff to wait for Weaviate server availability before proceeding.

Prevention

Automate Weaviate server health checks and schema validation during deployment pipelines to ensure the server is running and schema is correct before client usage.

Python 3.9+ · weaviate-client >=3.0.0 · tested on 3.5.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.