Skip to main content

Local instances

Follow these steps to connect to a locally hosted Weaviate instance.

Local connection URL

Docker instances default to http://localhost:8080. The gRPC port, 50051, is also on localhost.

If your instance runs on Kubernetes, see the host and port values in your Helm chart's values.yaml file.

No authentication enabled

To connect to a local instance without authentication, follow these examples.

import weaviate

client = weaviate.connect_to_local()


Authentication enabled

To authenticate with a Weaviate API key, follow these examples.

# Set this environment variable
# WEAVIATE_API_KEY your Weaviate instance API key

import weaviate
from weaviate.auth import AuthApiKey

client = weaviate.connect_to_local(


OIDC authentication

For details on authentication with OpenID Connect (OIDC), see OIDC configuration.

For additional client examples, see OIDC authentication.

Third party API keys

Integrations that use external APIs often need API keys. To add third party API keys, follow these examples:

# Set this environment variable
# COHERE_API_KEY your Cohere API key

import os
import weaviate

client = weaviate.connect_to_local(
"X-Cohere-Api-Key": os.getenv("COHERE_API_KEY")


Environment variables


Do not hard-code API keys or other credentials in your client code. Use environment variables or a similar secure coding technique instead.

Environment variables keep sensitive details out of your source code. Your application imports the information to runtime.

Set an environment variable.

In these examples, the environment variable names are in UPPER_CASE.

export WEAVIATE_URL="http://localhost:8080"
export WEAVIATE_API_KEY="sAmPleKEY8FwELJILn0YDRG9gjy4hReqfInz"
Import an environment variable.
weaviate_url = os.getenv("WEAVIATE_URL")
weaviate_key = os.getenv("WEAVIATE_API_KEY")

gRPC timeouts

The Python client v4 and TypeScript client v3 use gRPC. The gRPC protocol is sensitive to network delay. If you encounter connection timeouts, adjust the timeout values for initialization, queries, and insertions.

import weaviate
from weaviate.classes.init import AdditionalConfig, Timeout

client = weaviate.connect_to_local(
timeout=Timeout(init=30, query=60, insert=120) # Values in seconds


Questions and feedback

If you have any questions or feedback, let us know in the user forum.