High severity intermediate · Fix: 5-10 min

ConnectionRefusedError

weaviate.exceptions.ConnectionRefusedError

What this error means
The Weaviate client failed to connect to the Weaviate server or the schema is incompatible, causing a connection refused or schema validation error.

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
Ensure the Weaviate server is running and the client URL matches the server address before making schema calls.

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, unreachable, or the URL is incorrect. Additionally, if the schema expected by the client does not match the server's schema, schema validation fails and raises this error.

Detection

Monitor connection attempts to the Weaviate server and catch ConnectionRefusedError exceptions; log schema validation results to detect mismatches before runtime failures.

Causes & fixes

1

Weaviate server is not running or unreachable at the specified URL

✓ Fix

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

2

Incorrect Weaviate client URL or port configuration

✓ Fix

Double-check and correct the Weaviate client initialization URL to match the running server's address and port.

3

Schema mismatch between client expectations and Weaviate server schema

✓ Fix

Synchronize the schema by updating the Weaviate server schema or adjusting the client schema definitions to match exactly.

4

Network firewall or proxy blocking connection to Weaviate server

✓ Fix

Configure network rules to allow traffic on the Weaviate server port or disable interfering proxies/firewalls.

Code: broken vs fixed

Broken - triggers the error
python
import weaviate

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

# This line raises ConnectionRefusedError if server is down
schema = client.schema.get()
print(schema)
Fixed - works correctly
python
import os
import weaviate

WEAVIATE_URL = os.environ.get('WEAVIATE_URL', 'http://localhost:8080')
client = weaviate.Client(url=WEAVIATE_URL)  # Fixed: use env var and ensure server is running

schema = client.schema.get()
print(schema)  # Successfully prints schema
Changed to use environment variable for URL and ensured the Weaviate server is running and reachable to avoid connection refused errors.

Workaround

Wrap schema calls in try/except ConnectionRefusedError, and retry connection after a delay or fallback to a cached schema if available.

Prevention

Implement health checks and connection retries before schema operations, and automate schema synchronization between client and server to avoid mismatches.

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.