Khoj uses environment variables and an admin panel for configuration. This guide covers Docker Compose environment variables, chat model setup, and operational best practices.
| Variable | Description | Example |
|---|---|---|
KHOJ_ADMIN_PASSWORD |
Secure admin password for first admin account | your-secure-password |
KHOJ_DJANGO_SECRET_KEY |
Secure Django secret key for sessions/crypto | your-secret-key-min-50-chars |
| Variable | Description | Default |
|---|---|---|
POSTGRES_DB |
PostgreSQL database name | postgres |
POSTGRES_USER |
PostgreSQL username | postgres |
POSTGRES_PASSWORD |
PostgreSQL password | postgres (change in production!) |
POSTGRES_HOST |
PostgreSQL host (Docker service name) | database |
POSTGRES_PORT |
PostgreSQL port | 5432 |
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key for GPT models |
ANTHROPIC_API_KEY |
Anthropic API key for Claude models |
GEMINI_API_KEY |
Google Gemini API key |
SERPER_DEV_API_KEY |
Serper.dev API key for web search |
OLOSTEP_API_KEY |
Olostep API key for webpage reading |
FIRECRAWL_API_KEY |
Firecrawl API key for web search/read |
EXA_API_KEY |
Exa.ai API key for web search |
| Variable | Description | Example |
|---|---|---|
OPENAI_BASE_URL |
Custom OpenAI-compatible API endpoint | http://localhost:11434/v1/ (Ollama) |
KHOJ_DEFAULT_CHAT_MODEL |
Default chat model name | qwen3, gpt-4o, claude-3-5-sonnet-20240620 |
| Variable | Description |
|---|---|
KHOJ_DOMAIN |
External domain or IP for remote access (no http/https prefix) |
KHOJ_NO_HTTPS |
Set to True for HTTP access (use with KHOJ_DOMAIN) |
KHOJ_ALLOWED_DOMAIN |
Internal domain/IP for load balancer/reverse proxy setups |
KHOJ_ADMIN_EMAIL |
Admin email address |
| Variable | Description |
|---|---|
KHOJ_OPERATOR_ENABLED |
Set to True to enable Khoj computer operator feature |
KHOJ_TELEMETRY_DISABLE |
Set to True to disable telemetry |
KHOJ_DEBUG |
Set to True for debug mode (development only) |
| Variable | Description | Default |
|---|---|---|
KHOJ_TERRARIUM_URL |
Python sandbox URL for code execution | http://sandbox:8080 |
KHOJ_SEARXNG_URL |
SearxNG search URL | http://search:8080 |
E2B_API_KEY |
E2B remote code sandbox API key (alternative to Terrarium) |
POSTGRES_PASSWORD)KHOJ_ADMIN_PASSWORDKHOJ_DJANGO_SECRET_KEY (50+ characters)KHOJ_ALLOWED_DOMAIN when using reverse proxyAccess admin panel at http://localhost:42110/server/admin (use localhost, not 127.0.0.1)
For Local Models (Ollama):
OPENAI_BASE_URL=http://host.docker.internal:11434/v1/qwen3)For Cloud Models:
| Data Type | Location | Backup Method |
|---|---|---|
| PostgreSQL Database | Docker volume khoj_db |
pg_dump or volume backup |
| Config Files | Docker volume khoj_config |
Copy ~/.khoj directory |
| Model Cache | Docker volume khoj_models |
Optional (can re-download) |
| Environment Variables | docker-compose.yml |
Version control (exclude secrets) |
| Secrets | Your secret manager | Store externally |
Database Backup:
docker-compose exec database pg_dump -U postgres postgres > khoj-backup.sql
Full Volume Backup:
tar -czf khoj-backup.tar.gz ~/.khoj
docker-compose up -dAny questions?
Feel free to contact us. Find all contact information on our contact page.