High severity beginner · Fix: 2-5 min

ValueError

chromadb.errors.ValueError: Collection not found

What this error means
This error occurs when a query is made against a ChromaDB collection that does not exist or was not created.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    results = collection.query(query_texts=["example query"])
  File "/usr/local/lib/python3.9/site-packages/chromadb/api/collection.py", line 120, in query
    raise ValueError("Collection not found")
chromadb.errors.ValueError: Collection not found
QUICK FIX
Call client.create_collection('your_collection_name') before querying to ensure the collection exists.

Why it happens

ChromaDB requires collections to be explicitly created before querying. If the collection name used in the query does not match any existing collection, the client raises this ValueError. This often happens due to typos, missing initialization, or querying before collection creation.

Detection

Check for ValueError exceptions with the message 'Collection not found' immediately after collection query calls to catch missing or misnamed collections before app failure.

Causes & fixes

1

The collection was never created before querying.

✓ Fix

Create the collection explicitly using client.create_collection('collection_name') before querying it.

2

The collection name used in the query is misspelled or does not match the created collection name.

✓ Fix

Verify and correct the collection name string to exactly match the created collection's name, including case sensitivity.

3

The client instance is connected to a different or empty ChromaDB database where the collection does not exist.

✓ Fix

Ensure the client is connected to the correct ChromaDB instance and database where the collection was created.

Code: broken vs fixed

Broken - triggers the error
python
from chromadb import Client
client = Client()
collection = client.get_collection('my_collection')
# This line raises ValueError: Collection not found
results = collection.query(query_texts=["test query"])
print(results)
Fixed - works correctly
python
import os
from chromadb import Client

# Use environment variable for any config if needed
client = Client()

# Create collection before querying (fix applied here)
collection = client.create_collection('my_collection')
results = collection.query(query_texts=["test query"])
print(results)  # Now works without error
Added client.create_collection() call to ensure the collection exists before querying, preventing the 'Collection not found' error.

Workaround

Catch the ValueError on query, then create the collection dynamically with client.create_collection() and retry the query.

Prevention

Always create and verify collections exist at application startup or deployment time before running queries to avoid runtime collection-not-found errors.

Python 3.9+ · chromadb >=0.3.0 · tested on 0.4.2
Verified 2026-04
Verify ↗

Community Notes

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