Dify is an open source platform for building AI apps without writing much code. You can make chatbots, agents, multi-step workflows and document Q&A apps on a visual canvas, then publish them as a web app, a website chat widget, an API or even an MCP server.
You can use it in two ways: Dify Cloud, which is hosted for you, or the free Community Edition, which you self-host with Docker. Self-hosting lets you connect local models through Ollama, so your data never leaves your machine.
This guide shows how to self-host Dify with Docker Compose, connect a cloud or local model, build your first chatbot, add a knowledge base, create a workflow, publish your app and fix common setup problems. It follows the official Dify README, Docker guide and docs as of November 2026 (Dify 1.20).
- What: an open source LLM app builder with workflows, RAG, agents and model management.
- Needs: 2+ CPU cores, 4 GB+ RAM, Docker, Docker Compose 2.35.0+ and OpenSSL.
- Install:
cd docker,cp .env.example .env, set the sandbox token,docker compose up -d. - Open:
http://localhost/installto create the admin account. - Local models: install the Ollama plugin and use
http://host.docker.internal:11434. - License: Apache 2.0 with extra conditions (no multi-tenant SaaS, keep the logo).
What You Can Build With Dify
| App type | What it does | Example |
|---|---|---|
| Chatbot | A model plus a prompt in a chat window | Internal Q&A assistant |
| Agent | A chat app that reasons and uses tools on its own | Data analysis helper that fetches and charts data |
| Workflow | Runs once from input to output on a visual canvas | Report generator, batch processing |
| Chatflow | A workflow behind every chat message | Guided support bot with structured steps |
On top of that you get a prompt IDE, a RAG pipeline that reads PDFs, PPTs and other files, logs and annotations for improving answers, and an API for every app. The docs mark the classic Agent type as legacy, with a new sandboxed Agent in beta that can run commands and handle files.
Dify Cloud vs Self-Hosted
| Dify Cloud | Self-hosted Community Edition | |
|---|---|---|
| Setup | Sign up at cloud.dify.ai | Docker Compose on your PC or server |
| Models | Built-in AI credits or your own API keys | Your own API keys or local models |
| Cost | Plans on the Dify pricing page | Free software; you pay for hosting and APIs |
| Data | Hosted by Dify | Stays on your machine |
| Extras | Load balancing and IP access control on paid plans | Full control of configuration |
If you want to try ideas quickly, start on Cloud. If you want privacy, local models or no monthly bill, self-host.
Self-Host Dify With Docker
The README lists a minimum of 2 CPU cores and 4 GB of RAM. You also need Docker with a running daemon, Docker Compose v2.35.0 or later (check with docker compose version) and OpenSSL.
- Get the code:
git clone https://github.com/langgenius/dify.git cd dify/dockerFor a pinned release, add
--branch <version>using a tag from the Dify releases page. - Copy the template:
cp .env.example .env - Generate a sandbox token:
openssl rand -hex 32 - Edit .env and paste the output as
DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN. Keep the defaultCOMPOSE_PROFILES=weaviate,postgresql,collaboration. - Start everything:
docker compose up -d docker compose ps --allWait for health checks to pass. The one-time
init_permissionsservice exiting with code 0 is normal. - Open
http://localhost/installand create your admin account.
Windows users can run this in Docker Desktop with WSL2. If port 80 is taken, change the published HTTP port in the root .env and use that port in the URL.
Upgrade safely
- Back up first:
cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)" - Update the code, keeping your existing
.envinstead of copying the template again. - Compare the new
.env.exampleand.defaultsfiles for changed settings. - Restart:
docker compose pullthendocker compose up -d.
Connect a Model Provider
Every Dify app needs at least one model provider. Providers are shared across the workspace, and only owners and admins can manage them.
- Open Integrations, Model Provider.
- Install a provider from the list or from the Dify Marketplace, for example OpenAI, Anthropic, Gemini or OpenRouter.
- Click Add API Key on its card and paste your key. Dify checks it before enabling the provider.
- Set Default Models (top right): a System Reasoning Model, an Embedding Model for knowledge bases, and optionally Rerank, Speech-to-Text and Text-to-Speech models.
Don’t skip the defaults. The docs warn that features stop working when their default is empty, for example knowledge bases need an embedding model.
Use Local Models With Ollama
For a fully local setup, connect Ollama through the official plugin.
- Install Ollama and pull a chat model and an embedding model:
ollama pull qwen3 ollama pull embeddinggemma - In Dify, open the Marketplace and install the Ollama plugin.
- Add a model under the Ollama provider:
- Model Name:
qwen3 - Base URL:
http://host.docker.internal:11434(or your PC’s LAN IP). Don’t add/api. - Model Type: Chat
- Model Context Length: match the model’s context window
- Function call support: Yes only for tool-capable models; Vision support: Yes only for vision models
- Model Name:
- Add the embedding model the same way with Model Type Text Embedding.
- Set them as defaults in Default Models.
Because Dify runs in Docker, localhost inside the container is not your PC. That’s why the plugin docs recommend host.docker.internal or a LAN IP. On Linux, make Ollama listen on all interfaces with OLLAMA_HOST=0.0.0.0.
Need help choosing a model? See our best Ollama models list, or run Ollama itself in a container with our Ollama Docker guide.
Build Your First Chatbot
- Create a new app in your workspace and choose Chatbot.
- Write the prompt. Define the persona, output format and rules. Click Generate if you want an LLM to draft it for you.
- Add variables for personal touches. Type
/then New Variable, for example:You are an onboarding assistant for new {{role}} hires. Keep answers friendly and concise, and respond in {{language}}. - Pick a model in the preview panel and send a test message.
- Compare models with Debug as Multiple Models, which runs up to 4 side by side.
- Click Publish when you’re happy.
Variable types include Short Text (up to 256 characters), Paragraph, Select, Number, Checkbox and API-based variables that fetch live data. Chatbots keep up to 500 messages or 2,000 tokens of history per conversation, dropping the oldest when either limit is hit.
Add a Knowledge Base (RAG)
- Open Knowledge and create a knowledge base.
- Import documents such as PDFs, slides and text files, or sync from Notion or a website.
- Choose chunking and indexing. High Quality indexing uses your embedding model.
- Attach it to your chatbot. Each user message is used as a search query, and the results are added to the prompt.
- Tune Retrieval Setting: rerank model or weighted score, Top K and a score threshold.
For large knowledge bases, use metadata filtering so the bot only searches the right documents. File upload limits default to 15 MB for documents and 10 MB for images, and you can raise them with environment variables.
Build a Workflow or Chatflow
Workflows give you control when a single prompt isn’t reliable enough. You connect nodes on a canvas, each handling one step, such as calling a model, retrieving knowledge, running code or branching on a condition.
| Workflow | Chatflow | |
|---|---|---|
| How users use it | Runs once per input | Runs on every chat message |
| Starts with | User Input or a Trigger | User Input |
| Ends with | Output node (optional) | Answer node (required) |
| Automation | Schedule, webhook or integration triggers | None; always starts from a message |
- Create an app and choose Workflow or Chatflow.
- Add nodes by dragging them onto the canvas and connecting them.
- Configure each node, for example the model and prompt in an LLM node.
- Run a test and check each node’s output.
- Publish to make it live.
Publish and Share Your App
| Option | Best for |
|---|---|
| Web app | Share a link instantly; find it on the app’s Access Point tab |
| API | Build Dify into your own product |
| Website embed | A chat widget or iframe on your existing site |
| MCP server | Use your app as a tool in Claude Desktop, Cursor and other MCP clients |
Publishing replaces the live version right away, so test before you click Publish. Prefer a ready-made chat interface for your own models instead? Compare with our LibreChat guide.
Before Going to Production
- Replace bundled credentials using the security template in the Docker folder.
- Set up HTTPS and trusted proxies as described in the Docker guide.
- Set public URLs by copying
urls.defaultstourls.envand editingCONSOLE_API_URLand related values. - Back up before every upgrade.
- Check the license: commercial use is allowed, but you need a commercial license to run multi-tenant SaaS or to remove Dify’s logo and copyright from the frontend.
Troubleshooting
Start with these three commands from the docker folder:
docker compose config --quiet
docker compose ps --all
docker compose logs --tail=100 api worker nginx
| Problem | Likely cause | Fix |
|---|---|---|
| Settings change has no effect | Edited a .example template |
Copy to .env; templates ending in .example aren’t loaded |
| Service still uses an old value | Containers not recreated | Run docker compose up -d; check root .env and shell variables |
| Overrides resolve strangely | Old Docker Compose | Upgrade to Compose v2.35.0 or later |
| Can’t reach Ollama | Using localhost inside Docker | Use http://host.docker.internal:11434 or your LAN IP |
| Knowledge base won’t index | No embedding model set | Set a default Embedding Model |
| Clone fails: “Remote branch null not found” | GitHub API rate limit | Clone with an explicit --branch <version> |
| Login drops on split subdomains | Cookies can’t reach both hosts | Set COOKIE_DOMAIN and NEXT_PUBLIC_COOKIE_DOMAIN=1 |
| “Too many emails” for everyone | Proxy hides visitor IPs | Configure Nginx real IP for your proxy |
Short on memory for local models alongside Dify’s containers? Our RAM for local AI guide helps you size your machine.
FAQ
Is Dify free?
The self-hosted Community Edition is free. Dify Cloud has its own plans, listed on the Dify pricing page.
Can I use Dify commercially?
Yes, including as a backend for your own apps. You need a commercial license only for multi-tenant SaaS or to remove the Dify logo from the frontend.
Can Dify run fully offline?
Yes, if you self-host and use local models through Ollama for both chat and embeddings.
What are the minimum requirements?
2 CPU cores and 4 GB of RAM for Dify itself, plus whatever your local models need.
What’s the difference between a Workflow and a Chatflow?
A Workflow runs once per input; a Chatflow runs behind every chat message and must end with an Answer node.
Can I use a Dify app inside Claude Desktop or Cursor?
Yes. Publish it as an MCP server.
Where do I open Dify after installing?
Go to http://localhost/install for first-time setup, then http://localhost afterwards.



