IndexNotFoundError
llama_index.storage.index_store.IndexNotFoundError
Stack trace
llama_index.storage.index_store.IndexNotFoundError: Index not found at the specified storage path: './storage/index.json'
Why it happens
This error occurs because LlamaIndex cannot find the index file at the given storage location. It usually means the index was never saved, the path is wrong, or the storage directory was deleted or moved.
Detection
Check for IndexNotFoundError exceptions when calling load_from_storage and verify the storage path exists and contains the expected index files before loading.
Causes & fixes
The index file was never saved to the specified storage path.
Ensure you call index.save_to_storage(storage_context) after creating the index to persist it before loading.
The storage path provided to load_from_storage is incorrect or misspelled.
Verify the exact path string passed to load_from_storage matches the location where the index was saved, including filename and extension.
The storage directory or files were deleted, moved, or corrupted after saving.
Check the storage directory manually to confirm the index files exist and restore or recreate the index if missing.
Code: broken vs fixed
from llama_index import StorageContext, load_index_from_storage
storage_context = StorageContext.from_defaults(persist_dir='./storage')
index = load_index_from_storage(storage_context) # Raises IndexNotFoundError if index missing import os
from llama_index import StorageContext, load_index_from_storage
os.environ['LLAMA_INDEX_PERSIST_DIR'] = './storage' # Set storage dir via env
storage_context = StorageContext.from_defaults(persist_dir=os.environ['LLAMA_INDEX_PERSIST_DIR'])
index = load_index_from_storage(storage_context) # Fixed: ensure path exists and index saved
print('Index loaded successfully') Workaround
Wrap load_index_from_storage in try/except IndexNotFoundError and fallback to creating a new index if loading fails.
Prevention
Always save the index immediately after creation with save_to_storage and verify storage paths programmatically before loading to prevent missing index errors.