Self-Hosted Khoj: AI Over Your Docs, Not Just Another Chat Box

You've got contracts in Google Drive, runbooks in Notion exports, meeting notes in Markdown, and a mental map of "I know we wrote this down somewhere." ChatGPT doesn't have access to any of it unless you paste it in — which means pasting client PDFs into a US SaaS account and hoping nobody screenshots the wrong thread.

Khoj is built for that gap. ~35k GitHub stars, self-hostable, and positioned as a personal AI second brain — chat with your documents, search the web, build custom agents, schedule research automations, and plug in local or cloud LLMs (Llama, Qwen, GPT, Claude, Gemini, Mistral). Not just a chat box. A retrieval and automation layer on top of knowledge you already have.

What it actually does

RAG over your files. Index PDFs, Markdown, Word docs, org-mode files, Notion exports, and images. Ask questions in natural language; Khoj retrieves relevant chunks from your library before the model answers. Semantic search works even when you don't remember the filename.

Web + docs together. The Docker stack includes SearxNG for privacy-oriented web search — research questions can pull from the internet and your indexed files in one conversation.

Custom agents. Define persona, knowledge scope, chat model, and tools. Spin up agents that behave like a legal reviewer, support triage bot, or industry newsletter curator — without building a custom app from scratch.

Automations. Schedule recurring research, personal newsletters, and smart notifications delivered to email or other channels. Less "open the chat app" and more "the summary shows up Monday morning."

Code execution sandbox. Terrarium runs Python in isolation when agents need to crunch data or run scripts — part of the official compose stack, not a bolt-on you wire yourself.

Access everywhere. Web UI, desktop, mobile, Obsidian, Emacs, WhatsApp — Khoj meets you where you work. Self-host the server; clients connect to your instance.

Khoj vs Open WebUI vs Jan

We've covered other local AI tools:

  • Open WebUI — excellent Ollama front end with RAG and multi-user chat
  • Jan — desktop ChatGPT feel with local models and a simple API

Khoj goes further on knowledge workflows: scheduled automations, custom agents with tools, deeper document indexing, and integrations (Obsidian, WhatsApp). Open WebUI wins if you mainly want team chat over Ollama. Jan wins for a lightweight desktop app. Khoj wins when your docs are the product and you want research that runs on a schedule.

Why self-host?

Your library stays yours. Contracts, HR policies, client briefs — indexing them on your Canadian VPS beats uploading to a multi-tenant AI SaaS.

Pick your models. Point Khoj at OpenAI, Anthropic, Gemini APIs, or set OPENAI_BASE_URL to Ollama, vLLM, or LM Studio on your network. Hybrid setups are normal: cloud model for hard reasoning, local model for sensitive docs.

PIPEDA-friendly story. Postgres with pgvector, document embeddings, and chat history on infrastructure you choose — including Canadian hosting.

What running it takes

Docker Compose is the recommended path. Download the official docker-compose.yml from the Khoj repo — it pulls:

  • Khoj serverghcr.io/khoj-ai/khoj:latest on port 42110
  • PostgreSQL + pgvector — document embeddings and app data
  • SearxNG — web search
  • Terrarium — sandboxed code execution

Set KHOJ_ADMIN_PASSWORD, KHOJ_DJANGO_SECRET_KEY, and change the default Postgres password before exposing anything to the internet. Add OPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY for cloud models — or uncomment OPENAI_BASE_URL for Ollama at http://host.docker.internal:11434/v1/.

RAM: plan 8 GB minimum, 16 GB if you're running local embedding models or large document libraries. Khoj getting "Killed" in Docker usually means bump RAM limits — the indexer is hungry during first import.

HTTPS via reverse proxy; set KHOJ_DOMAIN for remote access. Back up Postgres (pg_dump) and the khoj_config volume. Model caches can be re-downloaded; your indexed documents and chat history cannot.

Who it's for (and who should skip it)

Good fit: consultants with large document libraries, researchers who want scheduled digests, Obsidian users wanting AI over their vault, teams needing agents without building LangChain glue from scratch.

Maybe skip it: if you only need casual chat with Ollama — Open WebUI is simpler ops. If you won't maintain Postgres, SearxNG, and four containers, Khoj's cloud app at app.khoj.dev exists. If document indexing sounds like overhead for three PDFs, start smaller.

Hosting it in Canada

We deploy Khoj on Canadian Docker hosting — pgvector Postgres, TLS, API key management, and backup scope that includes embeddings and chat history. GPU optional for local models; many setups use cloud APIs for inference and self-host only the knowledge layer.

Tell us library size and whether you need local or cloud LLMs — we'll size RAM for indexing and keep the compose stack on one manageable box.

Tags:
  • Khoj
  • AI
  • RAG
  • Self-Hosted
  • Docker

Need Help With Your Hosting?

Tell us about your application — we respond within 1 hour with honest recommendations.