# PermissionError: [Errno 13] Permission denied: '/app/data/index_store.json' — LlamaIndex cannot persist index to storage

- **ID:** `llm/llamaindex-persist-dir-permission`
- **Domain:** llm
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

LlamaIndex requires write permissions to the persist directory; when running in containers or restricted environments, the application user lacks write access to the specified path.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| llama-index>=0.10.0 | active | — | — |
| llama-index-core>=0.10.0 | active | — | — |

## Workarounds

1. **Ensure the persist directory exists and is writable by the application user: mkdir -p /app/data && chown -R appuser:appuser /app/data** (95% success)
   ```
   Ensure the persist directory exists and is writable by the application user: mkdir -p /app/data && chown -R appuser:appuser /app/data
   ```
2. **Use a Docker volume with proper permissions: docker run -v ./data:/app/data my-app, and set the user ID in the Dockerfile to match the host user.** (90% success)
   ```
   Use a Docker volume with proper permissions: docker run -v ./data:/app/data my-app, and set the user ID in the Dockerfile to match the host user.
   ```
3. **Configure LlamaIndex to use a different storage backend like S3 or GCS that bypasses filesystem permissions: from llama_index.storage.storage_context import StorageContext; from llama_index.storage.docstore.s3 import S3DocumentStore** (85% success)
   ```
   Configure LlamaIndex to use a different storage backend like S3 or GCS that bypasses filesystem permissions: from llama_index.storage.storage_context import StorageContext; from llama_index.storage.docstore.s3 import S3DocumentStore
   ```

## Dead Ends

- **** — Running as root is a security risk and may not be allowed in production environments with security policies (70% fail)
- **** — /tmp is ephemeral and may be cleared on container restart or by system cleanup, losing persisted index data (80% fail)
- **** — Disabling persistence means the index must be rebuilt on every restart, increasing latency and API costs (60% fail)
