This guide walks through a self-hosted installation of Khoj using Docker Compose or pip.
| Requirement | Details |
|---|---|
| RAM | 8 GB minimum (16 GB VRAM recommended for offline/local models) |
| Disk Space | 5 GB minimum available |
| GPU | NVIDIA, AMD GPU, or Mac M1+ (significantly speeds up chat responses) |
| Operating System | Linux, macOS, Windows (with Docker Desktop or WSL2) |
Docker:
Pip Installation:
brew install rustup && rustup-initFor Docker installation, see Docker.
mkdir -p ~/.khoj && cd ~/.khoj
wget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.yml
Edit the docker-compose.yml file and set the following required variables:
nano docker-compose.yml
Required Environment Variables:
KHOJ_ADMIN_PASSWORD - Secure admin passwordKHOJ_DJANGO_SECRET_KEY - Secure Django secret keyOptional Environment Variables:
KHOJ_ADMIN_EMAIL - Admin email addressOPENAI_API_KEY - OpenAI API keyANTHROPIC_API_KEY - Anthropic API keyGEMINI_API_KEY - Gemini API keyOPENAI_BASE_URL - Custom OpenAI-compatible API URL (e.g., Ollama: http://localhost:11434/v1/)KHOJ_DOMAIN - External IP or domain for remote accessKHOJ_NO_HTTPS - Set to True for HTTP access (for custom domains)KHOJ_ALLOWED_DOMAIN - Internal IP or domain for load balancer/reverse proxy setupscd ~/.khoj
docker-compose up
Success indicator: 🌖 Khoj is ready to engage appears in server logs.
Open your browser to http://localhost:42110
By default, Khoj is only accessible on the local machine. For remote access:
KHOJ_DOMAIN=your-external-ip-or-domainKHOJ_NO_HTTPS=True (if not using HTTPS)macOS (ARM/M1+):
CMAKE_ARGS="-DGGML_METAL=on" python -m pip install 'khoj[local]'
macOS (Intel):
python -m pip install 'khoj[local]'
Linux:
# CPU only
python -m pip install 'khoj[local]'
# NVIDIA CUDA GPU
CMAKE_ARGS="-DGGML_CUDA=on" FORCE_CMAKE=1 python -m pip install 'khoj[local]'
# AMD ROCm GPU
CMAKE_ARGS="-DGGML_HIPBLAS=on" FORCE_CMAKE=1 python -m pip install 'khoj[local]'
Windows (PowerShell):
# CPU only
py -m pip install 'khoj[local]'
# NVIDIA CUDA GPU
$env:CMAKE_ARGS = "-DGGML_CUDA=on"
py -m pip install 'khoj[local]'
USE_EMBEDDED_DB="true" khoj --anonymous-mode
Note: --anonymous-mode allows access without login (suitable for local, single-user setups).
Open your browser to http://localhost:42110
@reboot khojOn first run, you’ll be prompted to:
Access the admin panel at: http://localhost:42110/server/admin
⚠️ Important: Use localhost, not 127.0.0.1, to avoid CSRF errors.
https://ollama.comollama pull qwen3http://localhost:11434/v1/chat-model field (e.g., qwen3)model-type to OpenAIgpt-4o, claude-3-5-sonnet-20240620)model-type appropriatelyPip:
pip install --upgrade khoj
Docker:
cd ~/.khoj
docker-compose up --build
| Issue | Solution |
|---|---|
| Dependency conflicts | Install via pipx: pipx install khoj |
| Tokenizer build fails (Rust error) | Install Rust: brew install rustup && rustup-init |
| Docker “KILLED” error | Increase RAM in Docker Settings |
| CSRF error | Use localhost, not 127.0.0.1 |
| CSRF Trusted Origin error | Set KHOJ_ALLOWED_DOMAIN=your-internal-ip |
| DISALLOWED HOST / Bad Request 400 | Set KHOJ_DOMAIN=your-external-ip and KHOJ_NO_HTTPS=True |
| Safari admin login issues (Mac) | Use Chrome or Firefox instead |
Prefer automation? See Khoj Ansible Setup for an example playbook.
Prefer containers? See Khoj Docker Setup for the complete docker-compose.yml.
Any questions?
Feel free to contact us. Find all contact information on our contact page.