Cognee exposes several environment variables that let you harden a self-hosted deployment for production use. Some controls are enforced by default, while others remain permissive for local development, so you should review each setting before exposing Cognee to untrusted users or networks.Documentation Index
Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
Use this file to discover all available pages before exploring further.
Security Controls
Authentication
Authentication
Require authentication for all API requests
ENABLE_BACKEND_ACCESS_CONTROL is the canonical posture switch; REQUIRE_AUTHENTICATION is an optional override on the auth requirement alone.ENABLE_BACKEND_ACCESS_CONTROL | REQUIRE_AUTHENTICATION | Effective behavior |
|---|---|---|
true (default) | unset | Multi-tenant mode: per-user/dataset isolated DBs and API endpoints require an authenticated user. |
false | unset | Single-user mode: shared DB and auth requirement off. |
| any | true | Auth is forced on (useful for a single-user deployment behind a shared token). |
false | false | Auth off. |
true | false | Misconfiguration — multi-tenant mode always requires auth. Cognee logs a warning at startup and forces REQUIRE_AUTHENTICATION=true. |
At startup, Cognee logs an
auth posture: ... line summarizing the resolved decision and the reason (default, inherited from ENABLE_BACKEND_ACCESS_CONTROL, explicit REQUIRE_AUTHENTICATION, or forced on by multi-tenant mode). Use this log line to verify what is actually in effect after deployment.JWT token settings
FASTAPI_USERS_JWT_SECRET must be the same across all instances (e.g., all Kubernetes pods) so that a token issued by one pod is accepted by another. Use a long, randomly generated string in production and never commit the real value to version control.JWT_LIFETIME_SECONDS controls how long a bearer token or cookie remains valid before the user must log in again.Data Protection
Data Protection
API Key Storage
false, API keys are stored as plaintext in the relational database.
When true, each key is hashed with SHA-256 before storage. The raw key is shown to the user only once at creation time and cannot be recovered afterward.Local File System Access
true, Cognee accepts local filesystem paths as data sources (e.g., /etc/passwd). This is convenient for local development but dangerous when Cognee is exposed as a multi-user backend — an authenticated user could read arbitrary files that the Cognee process has access to.Set to false when running Cognee as a backend service:Cypher Query Access
true, users can execute raw Cypher queries against the graph database (SearchType.CYPHER) and use natural language-to-Cypher translation (SearchType.NATURAL_LANGUAGE). Disable this to limit users to higher-level semantic search only:Encrypting Neo4j Aura Credentials
When using theneo4j_aura_dev dataset database handler for multi-user mode, Cognee stores per-dataset Neo4j Aura database connection info in the relational database. The stored database password is encrypted with Fernet symmetric encryption; the encryption key is derived from NEO4J_ENCRYPTION_KEY:"test_key" is intentionally insecure. Replace it with a long random string in any environment that stores real Neo4j Aura credentials.The Aura API credentials used to create or delete instances (
NEO4J_CLIENT_ID, NEO4J_CLIENT_SECRET, and NEO4J_TENANT_ID) are read from environment variables when needed and are not stored in the relational database by this handler.Multi-User Isolation
Multi-User Isolation
Dataset & Multi-User Isolation
| Layer | Supported backends |
|---|---|
| Relational | SQLite, PostgreSQL |
| Vector | LanceDB, PGVector |
| Graph | Kuzu, Neo4j Aura (neo4j_aura_dev handler) |
ENABLE_BACKEND_ACCESS_CONTROL=false alone also disables the auth requirement (single-user mode). You only need to add REQUIRE_AUTHENTICATION if you want to override that default — for example, REQUIRE_AUTHENTICATION=true to keep auth on for a single-user deployment behind a shared token.See Dataset Database Handlers for the full list of supported handlers.Disabling Authentication for Local Development
Disabling Authentication for Local Development
When running Cognee locally for development or testing, you can disable authentication so that API calls succeed without a bearer token. Setting the single posture switch is enough:With
ENABLE_BACKEND_ACCESS_CONTROL=false and REQUIRE_AUTHENTICATION unset, REQUIRE_AUTHENTICATION inherits from the posture switch and the auth requirement is turned off automatically. (Previously, both variables had to be set to false independently; that is no longer required.)These values are read once when the server process starts, so you must restart the server after changing them. Check the auth posture: ... line in the startup logs to confirm the resolved decision.When authentication is disabled, unauthenticated requests are automatically served under a built-in default user (default_user@example.com). The relational database must be initialized before the first request so that this default user can be looked up or created.Troubleshooting 401 errors after setting the variables| Symptom | Cause | Fix |
|---|---|---|
Still getting 401 on all endpoints | ENABLE_BACKEND_ACCESS_CONTROL is still true, or REQUIRE_AUTHENTICATION=true is set explicitly and overrides it | Set ENABLE_BACKEND_ACCESS_CONTROL=false and unset (or also set to false) REQUIRE_AUTHENTICATION |
| Startup log says auth was “forced on by multi-tenant mode” | REQUIRE_AUTHENTICATION=false is combined with ENABLE_BACKEND_ACCESS_CONTROL=true — an unsafe combination that Cognee coerces to auth-on | To disable auth, also set ENABLE_BACKEND_ACCESS_CONTROL=false |
401 persists after editing .env | Server not restarted | Restart the server — the variables are evaluated at import time |
500 Failed to create default user | Relational DB not initialized | Call cognee.prune.prune_system() once, or let the server run its startup migrations before sending requests |
Recommended Production Settings
Recommended Production Settings
Recommended Production Settings
For detailed instructions on the multi-user permission system (users, tenants, roles, and ACL), see Cognee Permissions System.
Permissions Setup
Enable dataset isolation and access control
Multi-User Mode
Understand multi-tenant architecture