mem0ai/mem0 · error · TimeoutError
Index {name} creation timed out after {max_retries} seconds
Error message
Index {name} creation timed out after {max_retries} seconds What it means
TimeoutError raised after create_col polls for up to 180 seconds (1s sleep per attempt, counted once per failed probe) waiting for the newly created OpenSearch index to answer a match_all search. If the index never becomes queryable in that window, the loop gives up and the constructor/create path fails.
Source
Thrown at mem0/vector_stores/opensearch.py:149
if not self.client.indices.exists(index=name):
logger.warning(f"Creating index {name}, it might take 1-2 minutes...")
self.client.indices.create(index=name, body=index_settings)
# Wait for index to be ready
max_retries = 180 # 3 minutes timeout
retry_count = 0
while retry_count < max_retries:
try:
# Check if index is ready by attempting a simple search
self.client.search(index=name, body={"query": {"match_all": {}}})
time.sleep(1)
logger.info(f"Index {name} is ready")
return
except Exception:
retry_count += 1
if retry_count == max_retries:
raise TimeoutError(f"Index {name} creation timed out after {max_retries} seconds")
time.sleep(0.5)
def insert(
self, vectors: List[List[float]], payloads: Optional[List[Dict]] = None, ids: Optional[List[str]] = None
) -> List[OutputData]:
"""Insert vectors into the index."""
if not ids:
ids = [str(i) for i in range(len(vectors))]
if payloads is None:
payloads = [{} for _ in range(len(vectors))]
for idx, vec in enumerate(vectors):
if vec is None:
raise ValueError(
f"Vector at index {idx} is null. "
f"This usually means the embedding model failed to generate an embedding. "
f"Check that your embedding model is configured correctly and returning valid vectors."View on GitHub (pinned to 001c235229)
Solutions
- Check cluster health and index state: GET _cluster/health and GET <index>/_search, and look for red status or unassigned shards
- Freeze capacity: fix disk watermarks/heap, scale the cluster, then retry create_col
- For serverless, pre-warm the collection or raise the retry budget by constructing when the cluster is warm
- If creation genuinely failed, delete the half-created index and recreate
Example fix
# before
store = OpenSearch(...) # create_col internally times out after 180s
# after
# pre-check cluster, then construct with warm cluster
import opensearchpy
c = opensearchpy.OpenSearch(...)
assert c.cluster.health()["status"] in ("green", "yellow")
store = OpenSearch(...) Defensive patterns
Strategy: retry
Validate before calling
from opensearchpy import OpenSearch as OSClient
client = OSClient(...)
health = client.cluster.health()
if health.get("status") == "red":
raise RuntimeError("cluster red; fix shards/disk before creating indexes")
# index creation is then likely to converge inside the poll window Try / catch
try:
store = OpenSearch(...)
except TimeoutError as e:
if "creation timed out" in str(e):
time.sleep(30)
store = OpenSearch(...) # retry once cluster has settled
else:
raise Prevention
- Verify cluster green/yellow and disk below watermarks before creating indexes
- Pre-create indexes out of band (IaC) so app startup never waits on creation
- Warm serverless collections before first deploy; raise capacity if creation consistently exceeds 3 minutes
When it happens
Trigger: Creating an index on a cold/slow OpenSearch cluster (serverless cold start, undersized nodes), a cluster still forming shards, or one where index creation actually failed server-side while the poll only sees 'exception'.
Common situations: AWS OpenSearch Serverless first-hit latency; local OpenSearch under heavy load or low disk (watermark blocking shard allocation); security-timeout misconfig where search is rejected but creation 'succeeded'.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timed out waiting for Databricks endpoint ${this.endpointNam
- Baidu Mochow table '${this.tableName}' was not ${what} after
- Timed out waiting for Databricks index ${this.fullIndexName}
- Vector at index ${index} is null or undefined.
- Vector at index ${index} is empty. Expected dimension ${this
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/b369281ea6dbda46.
Report an issue: GitHub.