Deployment guide

How to host Khoj on a VPS

Deploy on a VPS Cloud →

Artificial Intelligence7 min read

How to host Khoj on a VPS

Khoj is a personal AI assistant that indexes your notes, documents and messages to make them semantically searchable, from your browser, Obsidian or Emacs. Hosting it on a VPS turns it into a knowledge copilot accessible anywhere, without giving up your data. Here is how to deploy it.

Why self-host Khoj on a VPS

Khoj stands out for its ability to sync with your sources (Markdown files, PDFs, Obsidian notes, Notion, GitHub) and to offer semantic search plus conversational answers. It also provides agents and web search. On a workstation, the index stays local to the machine; on a VPS, the Khoj server becomes a central access point that can be synced from several devices and plugins (Obsidian, Emacs, browser). You keep control of the vector index, you choose between a local LLM via Ollama or an API, and your personal or professional notes are never entrusted to the vendor's public cloud.

Concrete benefits of self-hosting

  • Centralized semantic index, syncable from several workstations and devices
  • Native Obsidian, Emacs and browser-extension integrations pointing to your server
  • Choice of LLM backend: local Ollama for privacy, or an external API if needed
  • Syncing of Markdown notes, PDFs, org-mode and repositories without exposing them to the cloud
  • Semantic search and conversational chat over your own personal corpus
  • Secure remote access to your knowledge base from anywhere

Hardware and software prerequisites

Khoj relies on a Django backend, a PostgreSQL database with pgvector and an embeddings model for indexing. Relying on an external API for chat, 2 vCPUs and 4 GB of RAM are amply sufficient, with 10 to 15 GB of disk depending on the size of your indexed corpus. If you add a local LLM via Ollama on the same VPS, raise this to 8 GB of RAM minimum. On the software side: Docker and Docker Compose, a domain pointing to the VPS, and optionally an LLM API key if you don't want a local model. The embeddings model is downloaded on first startup.

Deploying Khoj with Docker Compose

01

Grab the official compose

On the VPS, download the docker-compose.yml provided by Khoj. It declares the server, database (Postgres + pgvector) services and the configuration volume. Create a /opt/khoj folder to host the whole thing.

02

Configure the environment variables

Fill in KHOJ_DJANGO_SECRET_KEY, the Postgres credentials and, if you use an API, the provider's key. Set KHOJ_ADMIN_EMAIL and KHOJ_ADMIN_PASSWORD to create the administrator account at startup.

03

Start the services

Run docker compose up -d. On first startup, Khoj downloads the embeddings model, which can take a few minutes. Follow docker compose logs -f server until you see the server listening on port 42110.

04

Index your sources

Log in to the admin interface, configure the content paths or install the Obsidian/browser plugin, pointing its server URL to your VPS. Trigger a first sync and check that the index populates.

05

Reverse proxy and SSL

Place Caddy in front of port 42110: khoj.yourdomain.com { reverse_proxy localhost:42110 }. The Let's Encrypt certificate is generated automatically and all traffic goes over HTTPS.

06

Secure and connect the clients

Close port 42110 at the firewall, then configure the Obsidian, Emacs and browser extensions with the URL https://khoj.yourdomain.com and an API token generated in the settings for authenticated access.

Khoj can switch between several chat providers from its admin interface. Configure a local Ollama as the default backend for privacy, and declare an external API as a fallback only for complex queries: you get the best of both worlds, everyday privacy and occasional quality, without paying for every interaction.

Centralize your knowledge with Khoj

The ServOrbit Cloud VPS provides the Docker, PostgreSQL and fast SSD that Khoj needs to index and serve your knowledge base, accessible from all your devices.

Need help?

Browse our help center and FAQ, or write to our team — support in French, English and Arabic.