Dial tcp connect: connection refused (Local Ollama)


I am facing issues setting up a weaviate client with vectorizer and generative configurations. I am running Ollama Llama3 for my tasks. I am using Weaviate 1.25.

docker_compose.yml (The local weaviate server I am running):

version: '3.4'
    - --host
    - --port
    - '8080'
    - --scheme
    - http
    image: cr.weaviate.io/semitechnologies/weaviate:1.25.1
    - 8080:8080
    - 50051:50051
    - 11434:11434
    - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      ENABLE_MODULES: 'text2vec-ollama,generative-ollama,ref2vec-centroid,reranker-cohere,qna-openai'
      CLUSTER_HOSTNAME: 'node1'

Code (As mentioned in Quickstart, modified to use Ollama instead of OpenAI):

import weaviate
import weaviate.classes as wvc
from weaviate.classes.config import Property, DataType
from weaviate.connect import ConnectionParams
import ollama
import os
import requests
import json

client = weaviate.connect_to_local()

if client.collections.exists('Jeopardy'):
    print('Dropping pre-exisiting collection')
jeopardy_collection = client.collections.create(name='Jeopardy',

resp = requests.get('https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json')
jeopardy_data = json.loads(resp.text) 

question_objs = []

for i, data in enumerate(jeopardy_data):
        "answer": data["Answer"],
        "question": data["Question"],
        "category": data["Category"],

It runs well till here, then fails on insertion / update attempts:
with an error

Cell In[27], line 1
----> 1 jeopardy_collection.data.insert(jeopardy_data[0])

File ~/miniforge3/envs/weaviate/lib/python3.11/site-packages/weaviate/collections/data.py:388, in _DataCollection.insert(self, properties, references, uuid, vector)
    385 if vector is not None:
    386     weaviate_obj = self.__parse_vector(weaviate_obj, vector)
--> 388 return self._insert(weaviate_obj)

File ~/miniforge3/envs/weaviate/lib/python3.11/site-packages/weaviate/collections/data.py:82, in _Data._insert(self, weaviate_obj)
     79 path = "/objects"
     81 params, weaviate_obj = self.__apply_context_to_params_and_object({}, weaviate_obj)
---> 82 self._connection.post(
     83     path=path,
     84     weaviate_object=weaviate_obj,
     85     params=params,
     86     error_msg="Object was not added",
     87     status_codes=_ExpectedStatusCodes(ok_in=200, error="insert object"),
     88 )
     89 return uuid_package.UUID(weaviate_obj["id"])

File ~/miniforge3/envs/weaviate/lib/python3.11/site-packages/weaviate/connect/v4.py:500, in _Connection.post(self, path, weaviate_object, params, error_msg, status_codes)
    492 def post(
    493     self,
    494     path: str,
    498     status_codes: Optional[_ExpectedStatusCodes] = None,
    499 ) -> Response:
--> 500     return self.__send(
    501         "POST",
    502         url=self.url + self._api_version_path + path,
    503         weaviate_object=weaviate_object,
    504         params=params,
    505         error_msg=error_msg,
    506         status_codes=status_codes,
    507     )

File ~/miniforge3/envs/weaviate/lib/python3.11/site-packages/weaviate/connect/v4.py:451, in _Connection.__send(self, method, url, error_msg, status_codes, weaviate_object, params)
    449     res = self._client.send(req)
    450     if status_codes is not None and res.status_code not in status_codes.ok:
--> 451         raise UnexpectedStatusCodeError(error_msg, response=res)
    452     return cast(Response, res)
    453 except RuntimeError as e:

UnexpectedStatusCodeError: Object was not added! Unexpected status code: 500, with response body: {'error': [{'message': 'update vector: send POST request: Post "http://localhost:11434/api/embeddings": dial tcp connect: connection refused'}]}.

The server shows an error:

weaviate-1  | {"action":"requests_total","api":"rest","class_name":"Jeopardy","error":"update vector: send POST request: Post \"http://localhost:11434/api/embeddings\": dial tcp connect: connection refused","level":"error","msg":"unexpected error","query_type":"objects","time":"2024-05-28T14:42:25Z"}

To give some context, this code runs well (which does not use Ollama connectors from Weaviate itself):

client = weaviate.connect_to_local()
documents = [
  "Llamas are members of the camelid family meaning they're pretty closely related to vicuñas and camels",
  "Llamas were first domesticated and used as pack animals 4,000 to 5,000 years ago in the Peruvian highlands",
  "Llamas can grow as much as 6 feet tall though the average llama between 5 feet 6 inches and 5 feet 9 inches tall",
  "Llamas weigh between 280 and 450 pounds and can carry 25 to 30 percent of their body weight",
  "Llamas are vegetarians and have very efficient digestive systems",
  "Llamas live to be about 20 years old, though some only live for 15 years and others live to be 30 years old",

# Create a new data collection
if client.collections.exists('docs'):
collection = client.collections.create(
    name = "docs", # Name of the data collection
        Property(name="text", data_type=DataType.TEXT), # Name and data type of the property

# Store each document in a vector embedding database
with collection.batch.dynamic() as batch:
  for i, document in enumerate(documents):
    # Generate embeddings
    response = ollama.embeddings(model = "llama3",
                                 prompt = document)

    # Add data object with text and embedding
        properties = {"text" : document},
        vector = response["embedding"],

# An example prompt
prompt = "What animals are llamas related to?"

# Generate an embedding for the prompt and retrieve the most relevant doc
response = ollama.embeddings(
  model = "llama3",
  prompt = prompt,

results = collection.query.near_vector(near_vector = response["embedding"],
                                       limit = 1)

data = results.objects[0].properties['text']

prompt_template = f"Using this data: {data}. Respond to this prompt: {prompt}"

# Generate a response combining the prompt and data we retrieved in step 2
output = ollama.generate(
  model = "llama3",
  prompt = prompt_template,


I need help fixing the connection issue with the weaviate server.

1 Like

I also have the same issue so I used http://ollama:11424 as vectorizer url with ollama refering to my ollama container

Hi @suprateembanerjee and @switch :wave:

If you are using Docker, could you try setting the endpoint like this:


As shown here? text2vec-ollama | Weaviate - Vector Database

Please let us know if that works for you. Thanks!

1 Like

It does! Thanks!

Ollama can also be run in a docker container in which case @switch’s address is more applicable over a docker network.