QdrantCollectionNotFoundError
qdrant_client.http.exceptions.QdrantCollectionNotFoundError
Stack trace
qdrant_client.http.exceptions.QdrantCollectionNotFoundError: Collection 'my_collection' not found
File "/app/main.py", line 42, in query_vectors
response = client.search(collection_name='my_collection', query_vector=vec)
File "/usr/local/lib/python3.9/site-packages/qdrant_client/http/api_client.py", line 123, in search
raise QdrantCollectionNotFoundError(f"Collection '{collection_name}' not found") Why it happens
This error occurs when the Qdrant client tries to access a collection that does not exist on the Qdrant server. It can happen if the collection was never created, was deleted, or the collection name is misspelled in the code.
Detection
Monitor API responses for HTTP 404 errors from Qdrant client calls and log the collection name being accessed to catch missing collections before critical failures.
Causes & fixes
The collection name used in the client call does not exist on the Qdrant server.
Verify the collection name spelling and create the collection on the Qdrant server before querying or inserting.
The collection was deleted or dropped after initial creation.
Recreate the collection or update the client code to use an existing collection.
The Qdrant client is connected to the wrong server or environment where the collection is missing.
Check and correct the Qdrant server URL and environment configuration to point to the correct instance.
Code: broken vs fixed
from qdrant_client import QdrantClient
client = QdrantClient()
# This line triggers QdrantCollectionNotFoundError if collection doesn't exist
results = client.search(collection_name='my_collection', query_vector=[0.1, 0.2, 0.3]) import os
from qdrant_client import QdrantClient
client = QdrantClient(host=os.environ['QDRANT_HOST'], port=int(os.environ['QDRANT_PORT']))
# Create collection if missing before searching
if 'my_collection' not in [col.name for col in client.get_collections().collections]:
client.recreate_collection(collection_name='my_collection', vector_size=3, distance='Cosine')
results = client.search(collection_name='my_collection', query_vector=[0.1, 0.2, 0.3])
print(results) # Works without error now Workaround
Catch QdrantCollectionNotFoundError exceptions, then create the missing collection dynamically before retrying the operation.
Prevention
Implement initialization routines that ensure all required collections exist on Qdrant before runtime, and use environment-specific configs to avoid connecting to wrong servers.