To install Khoj AI, download the official docker-compose.yml file into a ~/.khoj folder, set secure values for KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY, then run docker-compose up in that folder. Open http://localhost:42110 when the logs say Khoj is ready to engage. Khoj is free to self-host under the AGPL-3.0 licence. Restart the server after the first run, as the official docs advise.
Your notes live in five places. Your documents live in three more. The answer you need is in one of them, and finding it still takes twenty minutes.
Khoj attacks that exact problem. This guide shows how to install Khoj AI personal assistant self hosted with Docker Compose, set the admin login and chat model, sync your first documents, secure the instance, back it up, update it, and fix the errors that stop most first installs.
Quick Answer
To install Khoj AI, download the official docker-compose.yml file into a ~/.khoj folder, set secure values for KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY, then run docker-compose up in that folder. Open http://localhost:42110 when the logs say Khoj is ready to engage. Khoj is free to self-host under the AGPL-3.0 licence. Restart the server after the first run, as the official docs advise.
In this article
- How we checked this guide
- What Khoj replaces, and what it does not
- Docker or Pip: which route fits your business
- Requirements before you install Khoj AI
- Step 1: install Khoj AI with Docker Compose
- Step 2: log in to the admin panel and add a chat model
- Step 3: sync your knowledge and ask your first question
- Step 4: agents, automations, and clients
- First-run security steps you must not skip
- Make Khoj useful for real work
- Backup and update routine
- Common errors and fixes
- Tips and tricks that save time
- The real cost maths: Khoj versus ChatGPT Plus
- When not to self-host Khoj
- Pros and cons
- Our verdict
- FAQ
- Strategic Pivot: price the whole stack before you switch
- Sources
How we checked this guide
We checked the install steps, admin setup, chat-model configuration, knowledge sync, upgrade notes, and troubleshooting fixes in the official Khoj self-host documentation. We checked the licence, feature list, and supported document types in the official Khoj GitHub repository. We checked the service list, volumes, port, and environment variables in the official docker-compose.yml file on GitHub.
The paid comparison uses OpenAI’s official Help Center page. That page lists ChatGPT Plus at $20 a month, billed monthly. It also states that API usage is separate and billed independently. Every command in this guide comes from those official sources, checked on December 1, 2026.
What Khoj replaces, and what it does not

Khoj replaces the hunt through your own files. The official repository calls Khoj your AI second brain. It answers from your documents and from the web. It also builds custom agents, schedules automations, and runs deep research with a local or online model you choose.
That makes Khoj different from a plain chat screen. A chat screen answers from the model’s training. Khoj first searches your notes and documents with semantic search. It then answers with references to the material it used. For business notes, manuals, and proposals, your own files are usually the safer source.
The official repository lists answers from image, PDF, Markdown, org-mode, Word, and Notion files. It lists access from the browser, Obsidian, Emacs, Desktop, Phone, and WhatsApp. It also lists custom agents with their own knowledge, persona, chat model, and tools. Scheduled automations can send research results and smart notifications to your inbox.
Khoj does not remove the model question. A chat model still generates every answer. That model can run locally through an OpenAI-compatible endpoint, or at a cloud provider through an API key. Document quality also still matters. A messy, outdated file produces messy answers, however good the search is.
The licence needs plain words. Khoj uses the GNU Affero General Public License v3.0, known as AGPL-3.0. You may run, study, modify, and share the software. If you offer a modified version to others over a network, the licence requires you to provide the corresponding source under the same licence. Internal business use does not trigger that sharing duty by itself.
Best for: a small-business owner, freelancer, or team lead who wants one private assistant over personal notes and business documents, with agents and scheduled research on hardware they control. Skip if: you want a hosted product with zero server care, or your team needs a multi-user document workspace first.
Khoj sits beside our document-chat guide, not on top of it. Our guide to install AnythingLLM to chat with business documents covers workspaces built around document sets. Choose Khoj when the job is a personal second brain across notes, files, and clients. Choose AnythingLLM when the job is team workspaces over business documents.
Our wider local-AI series helps you pick the model layer. Our guide to install Ollama on Ubuntu covers a local model runner. Our guide to install Open WebUI with Ollama covers a general chat front end. Our guides to install LibreChat self hosted AI chat, install LobeChat self hosted AI assistant, and install NextChat self hosted ChatGPT UI cover chat workspaces.
Docker or Pip: which route fits your business
Docker Compose is the right first install for most business readers. The official docs give Docker and Pip as the two install routes. The Compose file starts the Khoj server together with its database and helper services. One command brings the whole stack up on port 42110.
The Compose stack is worth understanding before you start it. The official file defines a PostgreSQL database with pgvector for storage and search. It defines a Terrarium sandbox for code execution. It defines a SearxNG service for web search. It also defines an optional computer service that stays off unless you enable the operator setting.
The Pip route fits Python users who prefer one process to manage. The docs install Khoj from the Python package, and the troubleshooting section recommends a virtual environment or pipx to avoid dependency conflicts. Pip suits a solo test on a machine you already maintain. Docker suits a server you expect to keep.
Do not build from source for a first business install. The Compose file uses the official ghcr.io/khoj-ai/khoj:latest image by default. Building from source is an option in the file for people changing the code. Pull the official image instead. You get the same app with far fewer moving parts.
Requirements before you install Khoj AI
You need Docker with the Docker Compose tool on the machine that will run Khoj. The official docs point to Docker Desktop, and they note that Compose must be installed as well. On a Mac, the docs also give Homebrew commands for Docker and Docker Compose. Install both before you download anything.
You need a model plan before setup. Khoj supports local and online chat models. The docs name OpenAI, Anthropic, and Gemini commercial models through API keys. They also name Ollama on your host machine through an OpenAI-compatible base URL. Decide that route now, because setup asks for it.
Plan storage around the Compose volumes. The official file stores configuration, the database, downloaded models, search data, and computer data in named Docker volumes. Your documents and index grow inside that storage. Give the host disk room to grow, and include those volumes in your backup plan from day one.
Plan memory for a multi-service stack. The docs warn that a Docker error reading Killed usually means Docker needs more RAM. A local model on the same machine needs memory of its own.
Keep the first install local while you test. The docs state that Khoj is only accessible on its own machine by default. Add remote access later, with security finished first.
Step 1: install Khoj AI with Docker Compose

Create the Khoj folder and download the official Compose file. The docs give these commands:
mkdir ~/.khoj && cd ~/.khoj
wget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.yml
Open docker-compose.yml and configure the environment variables before the first start. Set KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY to secure values. Set KHOJ_ADMIN_EMAIL as well if you want a named admin account. The docs state that these values let you customise Khoj later through the admin panel.
Add a model key only for the provider you will use. Set OPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY for a commercial chat model. For a local model, uncomment OPENAI_BASE_URL and point it at Ollama on your host machine, or at another OpenAI-compatible API such as vLLM or LM Studio.
Change the placeholder secrets in the file, not just the admin password. The Compose file ships example values for the database password and the Django secret key. Replace every placeholder with your own long random value. A self-hosted assistant with example secrets is an open filing cabinet.
Start Khoj from the folder that holds the Compose file. The docs give this command:
docker-compose up
Watch the logs while the services start. The docs state that setup is complete once you see the message that Khoj is ready to engage. The server waits for the database health check before it starts, so a short pause is normal.
Restart the server after the first run. The docs advise this step so all settings apply correctly. Then open http://localhost:42110 and start interacting. If the page does not load, check that the containers are running and that port 42110 is free.
Step 2: log in to the admin panel and add a chat model
Open the admin panel at http://localhost:42110/server/admin and log in with the admin credentials from your Compose file. Use the word localhost in that address, not 127.0.0.1. The docs warn that the numeric address can trigger a CSRF error in the admin panel.
Create a new AI Model Api entry in the server admin settings. Add your provider API key, and give the configuration a friendly name such as OpenAI. Set the API base URL only when you use an OpenAI-compatible proxy such as Ollama or LM Studio. Leave it empty for a direct provider connection.
Create a new chat model entry next. Set the chat-model field to a model your provider offers, such as the OpenAI example in the docs. Set the model-type field to match the provider. Turn on the vision enabled field only for an OpenAI model with vision capability, as the docs instruct.
Leave the tokenizer and max-prompt-size fields alone unless you know the values. The docs mark both fields optional. They improve context handling when set correctly. Guessed values help nobody, so set them only when you are sure.
Set your default chat model when you configure more than one model. The docs place the Default and Advanced fields in the ServerChatSettings entry. Khoj uses those models for intermediate steps such as intent detection and web search. A weak default model weakens every answer, not just the final one.
For Ollama on the host machine, use the host address from inside Docker. The Compose file sets host.docker.internal to reach the host gateway. Point OPENAI_BASE_URL at that address with the Ollama port and the /v1/ path. Inside a container, localhost means the container itself, not your machine.
Test the model with one plain question before you sync documents. That order separates model problems from document problems.
Step 3: sync your knowledge and ask your first question
Start with one small, clean document set. The docs state that you can drag and drop specific files in the web app. Upload a policy, a price list, or a manual whose answers you already know. Small sets make wrong answers easy to spot.
Ask questions the way you ask them at work. A real question tests search, the model, and the reference together. Check the cited source before you trust the answer. Khoj shows references for the material it used, and that habit is your trust check.
Sync a folder when the first test passes. The docs state that Khoj can keep files and folders synced through the Desktop, Obsidian, or Emacs clients. A Notion workspace can sync directly from the web app. Pick the client that matches where your notes already live.
Set the host URL in each client to your Khoj server address. The docs give http://127.0.0.1:42110 or http://localhost:42110 as the default local server URL. They also note that localhost may not work in all cases. Use the address that loads the web app on that device.
Keep document quality high at the source. Khoj searches the text you give it. Scanned pages with broken text produce broken retrieval. Replace poor scans with clean files where you can. Remove outdated versions so old prices stop answering new questions.
Watch what happens with a question your documents cannot answer. A confident invented answer is a warning sign. Tighten the set or the model when that happens.
Step 4: agents, automations, and clients

Create an agent only after plain document chat works. The official repository describes agents with custom knowledge, persona, chat model, and tools. An agent suits a repeated job, such as research over one document set. Give each agent a narrow job and a named owner.
Treat agent tools as permissions, not decorations. An agent with web search, code execution, or computer access can do more than answer. Start with search and documents. Add stronger tools one at a time, and test the result after each change.
Schedule an automation for research you repeat. The docs describe automations as scheduled jobs that run a query at a set time and frequency. Khoj sends the research result as an email. A weekly competitor scan or a daily topic digest fits that shape well.
Test every automation with one manual run first. Check the first result by hand, then let the schedule carry it.
Use clients where the work happens. The web app covers chat, search, and configuration by default. Obsidian and Emacs clients suit note-heavy users. The Desktop client suits a main computer. WhatsApp access suits quick questions away from a desk, once the server is reachable and secured.
Keep the computer service off unless you need it. The Compose file defines a computer container for Khoj to use, and the operator setting enables it. That power needs a clear job and a careful owner. Most small-business installs should leave it off.
First-run security steps you must not skip
Treat the instance like a filing cabinet with a chat window. Anyone with access can ask questions about your documents. Access control is therefore document control, and the admin password is the first lock.
Replace every placeholder secret before the first public start. The Compose file ships example values for the admin password, the Django secret key, and the database password. Set long random values for each one. Store them in a password manager, never in a document Khoj can search.
Read the server command before you share the address. The official Compose file starts the server with anonymous mode and non-interactive flags. Anonymous mode suits a private first test on your own machine. It does not suit a shared network or a public address. Remove anonymous access before anyone else can reach the server.
Keep the first install on localhost while you test. The docs state that Khoj is only accessible on its own machine by default. Remote access needs the domain settings in the docs, plus HTTPS and strong accounts. A document system exposed without those controls risks your files, not just your chat history.
Set the domain variables correctly when you add remote access. The docs give KHOJ_DOMAIN for the external address and KHOJ_NO_HTTPS=True only when HTTPS is not in use. Behind a load balancer or reverse proxy, KHOJ_ALLOWED_DOMAIN avoids CSRF and cookie errors. Wrong values here produce login errors that look like password problems.
Decide the telemetry question openly. The Compose file includes a commented line to disable telemetry, with a link to the telemetry docs. Set KHOJ_TELEMETRY_DISABLE=True for a stricter private setup. Telemetry settings do not stop calls to a cloud model or web service you configured.
Review outbound connections too. A private install means local models, local search where possible, and telemetry off. Anything else is a policy choice, so make it deliberately.
Make Khoj useful for real work
Build knowledge sets around decisions. A sales set can hold price lists, discount rules, and delivery terms. A support set can hold manuals and warranty rules. Focused sets produce focused answers, and focused answers are easier to verify.
Use references as the trust check. Khoj grounds answers in your documents and shows the material it used. Teach one rule: no reference, no customer promise. That single habit prevents most document-chat damage.
Use semantic search for the questions keywords miss. Ask in plain language, then open the source note before you act.
Refresh documents on a schedule. Price lists and policies change. Replace the file when the business version changes. Then re-ask your three test questions. A stale index answers with stale confidence.
Backup and update routine
Back up the Compose file and the Docker volumes together. The official file stores configuration, database data, models, search data, and computer data in named volumes. The Compose file holds your secrets and provider settings. A backup with only one half restores only half a system.
Back up before every update. Stop the stack cleanly, copy the volumes and the Compose file, then update. Test that the backup restores before you need it. An untested backup is a hope, not a backup.
Update the Pip route with the documented command. The docs give pip install --upgrade khoj for the server upgrade. They also note a pre-release upgrade path for readers who want the newest build. Restart the server after the upgrade and re-run your test questions.
Update the Docker route through the official image. The Compose file uses the latest official Khoj image by default. Pull the newer image, restart the stack, and check the ready message in the logs. The docs advise a restart after the first run so settings apply correctly, and the same habit suits every update.
Update clients on their own cycle. The Desktop app updates automatically on restart, per the docs. Check each client host URL after every move.
Common errors and fixes
A CSRF error in the admin panel usually means the wrong address. The docs instruct you to use localhost, not 127.0.0.1, for the admin panel. Change the address before you change the password. The password is probably fine.
A CSRF trusted origin or unset cookie error points at the domain settings. Behind a load balancer or reverse proxy, set KHOJ_ALLOWED_DOMAIN to the internal address. The docs state that it defaults to KHOJ_DOMAIN when unset. Match the value to the address your proxy actually uses.
A Disallowed Host or Bad Request 400 error points at the external address. The docs give KHOJ_DOMAIN for the external IP or domain. They give KHOJ_NO_HTTPS=True when the server runs without HTTPS. Set both to match how readers reach the server.
A Docker error reading Killed points at memory. The docs advise increasing the RAM available to Docker containers in Docker settings. Raise the limit, restart the stack, and watch the logs. A local model on the same machine needs memory of its own.
A Pip dependency conflict points at the Python environment. The docs advise installing Khoj in a virtual environment or with pipx. The pipx route keeps Khoj dependencies away from your other Python packages. Reinstall cleanly instead of forcing versions.
A tokenizers build failure points at Rust. The docs state that the tokenizers dependency can fail while building and complain about Rust. Install Rust with the steps the docs give for your system. Then run the install again in the same clean environment.
An admin login failure in Safari points at the browser. The docs note that Safari on Mac might not log in to the admin panel. Try Chrome or Firefox before you reset anything. Browser quirks waste more setup time than real password problems.
An Ollama connection failure usually points at the address. Inside Docker, localhost reaches the container, not the host machine. Use host.docker.internal with the Ollama port in the base URL. The Compose file already maps that name to the host gateway.
Tips and tricks that save time
Prove the model before you sync documents. One plain question with no documents separates model problems from document problems. That order saves an hour of guessing later.
Sync one source first. Drag and drop a small file set before you connect a whole vault. Known answers expose weak retrieval fast. A full library hides the same weakness under volume.
Keep three test questions for every document set. Ask them after each sync, each model change, and each update. A falling score on known answers is your early warning. Fix the set before staff trust the answers.
Leave optional power off until it earns its place. Turn each tool on for a named job, and off when the job ends.
The real cost maths: Khoj versus ChatGPT Plus

Khoj charges no licence fee for a self-hosted install. The official repository lists the AGPL-3.0 licence and describes Khoj as open-source and self-hostable. Your costs sit elsewhere: hardware or hosting, electricity, admin time, and any cloud model or search API you connect.
ChatGPT Plus gives the paid anchor. OpenAI’s official Help Center page lists ChatGPT Plus at $20 a month, billed monthly. That is $240 a year for one person. OpenAI also states that API usage is separate and billed independently, so a Plus subscription does not pay for Khoj model calls.
| Option | Licence or subscription | Model cost | Hosting cost | Best for |
|---|---|---|---|---|
| Khoj self-hosted with a local model | $0 under AGPL-3.0 | $0 licence fee for the local model route | Your own machine or server | Private notes and documents on hardware you own |
| Khoj self-hosted with a cloud model | $0 under AGPL-3.0 | Provider API usage, billed separately | Your own machine or server | Stronger models with your documents kept in your instance |
| ChatGPT Plus | $20/month, billed monthly | Included in the subscription for the web app | None | A hosted assistant with zero server care |
Run the solo-owner scenario first. One owner who would otherwise pay for ChatGPT Plus pays $240 a year. The same owner running Khoj on a machine they already own, with a local model, pays $0 in licence and subscription fees. The licence saving is $240 a year, before electricity and admin time.
Add a cloud model and the maths changes shape. Khoj still charges $0 for the licence. The provider bills API usage separately, by use. Light use can stay far below a subscription. Heavy research use can pass it. Meter the first month before you claim a saving.
Add a rented server and the maths changes again. Hosting, storage, and backups cost money every month. Admin time costs money too, even when the admin is you. Khoj wins on licence cost every time. It wins on total cost only when the machine and the maintenance already fit your business.
Count the hidden costs honestly. A local model needs hardware that answers at a useful speed. Optional paid search APIs in the Compose file bill on their own terms.
When not to self-host Khoj
Do not self-host Khoj when nobody owns the server. Updates, backups, and access control need a named person. An unowned assistant becomes an unpatched document store. A hosted subscription fits that business better.
Do not self-host Khoj for a team document workspace first. Khoj centres on a personal second brain over notes and documents. Our guide to install AnythingLLM to chat with business documents covers team workspaces with multi-user permissioning. Pick the tool that matches the job in front of you.
Do not self-host Khoj when your documents cannot be cleaned. Khoj searches the text you give it. Broken scans and outdated files produce broken answers. Fix the source files first, or the assistant will repeat the mess with confidence.
Do not self-host Khoj when a local model cannot answer well enough. Test answer quality with your real documents, not with demo questions. A cloud model can close the gap, at API cost. A weak answer on a customer question costs more than either route.
Do not expose Khoj publicly to save setup time. Anonymous access, example secrets, and plain HTTP each look harmless alone. Together they hand your documents to strangers. Finish the security steps first, then share the address.
Pros and cons
Pros:
- Free to self-host under AGPL-3.0, with no Khoj licence fee.
- Semantic search and chat over PDF, Markdown, org-mode, Word, image, and Notion material.
- Custom agents with their own knowledge, persona, chat model, and tools.
- Scheduled automations that send research results by email.
- Browser, Obsidian, Emacs, Desktop, Phone, and WhatsApp access routes.
- Local or cloud chat models through OpenAI-compatible endpoints and provider keys.
Cons:
- A multi-service Docker stack needs more care than a light chat UI.
- A chat model is still required, and local model quality decides answer quality.
- Document quality decides retrieval quality, so messy files give messy answers.
- Public access needs HTTPS, strong accounts, domain settings, and maintenance.
- Cloud model and optional search API usage bill separately from any subscription.
- Agents, code execution, and the computer service add power that needs ownership and testing.
Our verdict
Install Khoj AI if your answers live across notes and documents and you want one private assistant over them. Start with Docker Compose on localhost, secure secrets, one tested model, and one clean document set. Add agents, automations, and remote access only after your known-answer questions pass.
Skip Khoj if you want a hosted assistant with no server care. Skip it if your first job is a team document workspace. For a solo owner or small team lead with documents worth searching, Khoj earns its place on your own hardware.
FAQ
Is Khoj free for business use?
Yes, for a self-hosted install. Khoj uses the AGPL-3.0 licence, which permits commercial use, modification, and sharing. If you offer a modified version to others over a network, you must provide the corresponding source under the same licence. Hosting and cloud API costs still bill separately.
How do I install Khoj AI with Docker Compose?
Create a ~/.khoj folder and download the official docker-compose.yml file from GitHub. Set secure values for KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY, plus any model keys you will use. Run docker-compose up in that folder, then open http://localhost:42110.
Does Khoj need a GPU?
No. Khoj runs with cloud models through API keys, or with local models through an OpenAI-compatible endpoint such as Ollama. A GPU helps a local model answer faster, but it is not required to install or test Khoj. The Docker stack itself needs enough RAM for its services.
Why can I not log in to the Khoj admin panel?
Check the address first. The docs instruct you to use localhost, not 127.0.0.1, to avoid a CSRF error. Behind a proxy, set KHOJ_ALLOWED_DOMAIN and KHOJ_DOMAIN to match your setup. On a Mac, the docs also suggest trying Chrome or Firefox instead of Safari.
Is Khoj private by default?
It can be. Your documents and index stay in your Docker volumes, and a local model keeps answers on your hardware. Set KHOJ_TELEMETRY_DISABLE=True for a stricter setup, and replace the anonymous-mode default before sharing the address. Cloud models and web services still receive the calls you send them.
Strategic Pivot: price the whole stack before you switch
Khoj removes the licence fee. It does not remove hosting, model, or admin costs. Before you move a team onto any self-hosted stack, price the full year, not the first month. Our free AI Cost Calculator helps you compare a lean local setup against a full paid stack with your own numbers.
Sources
- Official Khoj self-host documentation: install routes, Docker setup, admin panel, chat models, knowledge sync, clients, upgrade, and troubleshooting.
- Official Khoj GitHub repository: AGPL-3.0 licence, feature list, supported document types, and self-host links.
- Official Khoj
docker-compose.ymlon GitHub: services, volumes, port 42110, environment variables, and telemetry setting. - OpenAI Help Center, What is ChatGPT Plus: $20/month billed monthly, with API usage separate and billed independently.
Price note — updated December 2, 2026: Prices in this post were checked on December 2, 2026. When you are reading this, the price may be lower or higher — always check the official pricing page before you buy.
Pros
- Free to self-host under AGPL-3.0, with no Khoj licence fee
- Semantic search and chat over PDF, Markdown, org-mode, Word, image, and Notion material
- Custom agents with their own knowledge, persona, chat model, and tools
- Scheduled automations that send research results by email
- Browser, Obsidian, Emacs, Desktop, Phone, and WhatsApp access routes
- Local or cloud chat models through OpenAI-compatible endpoints and provider keys
Cons
- A multi-service Docker stack needs more care than a light chat UI
- A chat model is still required, and local model quality decides answer quality
- Document quality decides retrieval quality, so messy files give messy answers
- Public access needs HTTPS, strong accounts, domain settings, and maintenance
- Cloud model and optional search API usage bill separately from any subscription
- Agents, code execution, and the computer service add power that needs ownership and testing
Install Khoj AI if your answers live across notes and documents and you want one private assistant over them. Start with Docker Compose on localhost, secure secrets, one tested model, and one clean document set. Add agents, automations, and remote access only after your known-answer questions pass.

1 thought on “How to Install Khoj AI Personal Assistant Self Hosted (2026)”