Skip to content

How to Use Dify (2026): Self-Host, Local Models, Chatbots and Workflows

8–12 minutes
Delighted woman with a dark bob and pearl earrings in a burgundy sweater on a city rooftop at sunset holding a card reading DIFY, with the text Build AI Apps with Dify

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).

TL;DR

  • 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/install to 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.

  1. Get the code:
    git clone https://github.com/langgenius/dify.git
    cd dify/docker

    For a pinned release, add --branch <version> using a tag from the Dify releases page.

  2. Copy the template:
    cp .env.example .env
  3. Generate a sandbox token:
    openssl rand -hex 32
  4. Edit .env and paste the output as DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN. Keep the default COMPOSE_PROFILES=weaviate,postgresql,collaboration.
  5. Start everything:
    docker compose up -d
    docker compose ps --all

    Wait for health checks to pass. The one-time init_permissions service exiting with code 0 is normal.

  6. Open http://localhost/install and 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

  1. Back up first: cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)"
  2. Update the code, keeping your existing .env instead of copying the template again.
  3. Compare the new .env.example and .defaults files for changed settings.
  4. Restart: docker compose pull then docker 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.

  1. Open Integrations, Model Provider.
  2. Install a provider from the list or from the Dify Marketplace, for example OpenAI, Anthropic, Gemini or OpenRouter.
  3. Click Add API Key on its card and paste your key. Dify checks it before enabling the provider.
  4. 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.

  1. Install Ollama and pull a chat model and an embedding model:
    ollama pull qwen3
    ollama pull embeddinggemma
  2. In Dify, open the Marketplace and install the Ollama plugin.
  3. 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
  4. Add the embedding model the same way with Model Type Text Embedding.
  5. 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

  1. Create a new app in your workspace and choose Chatbot.
  2. Write the prompt. Define the persona, output format and rules. Click Generate if you want an LLM to draft it for you.
  3. 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}}.
  4. Pick a model in the preview panel and send a test message.
  5. Compare models with Debug as Multiple Models, which runs up to 4 side by side.
  6. 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)

  1. Open Knowledge and create a knowledge base.
  2. Import documents such as PDFs, slides and text files, or sync from Notion or a website.
  3. Choose chunking and indexing. High Quality indexing uses your embedding model.
  4. Attach it to your chatbot. Each user message is used as a search query, and the results are added to the prompt.
  5. 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
  1. Create an app and choose Workflow or Chatflow.
  2. Add nodes by dragging them onto the canvas and connecting them.
  3. Configure each node, for example the model and prompt in an LLM node.
  4. Run a test and check each node’s output.
  5. 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.defaults to urls.env and editing CONSOLE_API_URL and 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.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Delighted woman with a dark bob and pearl earrings in a burgundy sweater on a city rooftop at sunset holding a card reading DIFY, with the text Build AI Apps with Dify