Dify is an open-source platform for building AI applications in your browser: chatbots that answer questions using your own documents, agents that call tools, and workflows that chain multiple steps with language models. Dify does not include the language models themselves. You connect one or more model providers, such as OpenAI or Anthropic using an API key, or your own models through Ollama or LiteLLM. You can share finished apps as web apps using a link, embed them on your website, or call them through an API.
Dify consists of many services that work together: an API and worker, a web interface, PostgreSQL, Redis, the Weaviate vector database for knowledge bases, a sandbox for code steps, a proxy to prevent access to the internal network, and the plugin service. In this guide, we’ll show you two options: the easy way, using the One-Click App, where you don’t have to manage any of these services, and a manual installation with Docker Compose using the official guide. Then you’ll set up a model provider, build your first app, and create a knowledge base.
Dify is worth using if you want more than a chat with a model. Dify is a good fit on a VPS if:
- You need a chatbot for your own content, such as manuals, FAQs, or internal documents, that gets its answers from a knowledge base (RAG).
- You want to build AI workflows without programming, for example, to review, summarize, and format text, with branching and multiple models.
- You want to manage models from different providers in one place and choose the right model for each app.
- You want your documents and conversation histories stored on your own server rather than in a third-party cloud service.
- You want to add ready-made AI features to your own software through an API without having to program the logic yourself.
Dify is less suitable if you just want to chat with a model yourself. A lightweight interface such as Open WebUI, which is installed with Ollama, is enough for that. Dify also doesn’t run models itself: they run with a provider or on your own model server. And Dify needs significantly more RAM for its many services than most One-Click Apps.
You can find both apps in the app catalog, and both let you build workflows in a visual editor. However, they have different focuses:
| Dify | n8n | |
|---|---|---|
| Focus | AI applications: chatbots, agents, knowledge bases | Automation between services, with or without AI |
| Result | A finished chat app or workflow with a web interface and API | A workflow that responds to triggers (schedule, webhook, new email) |
| Knowledge base (RAG) | Built in, with a vector database | Only through custom components and external services |
| Connecting to other services | Through plugins and HTTP steps | Hundreds of ready-made integrations |
In short: with Dify, you build the AI app itself; with n8n, you connect services to each other. You can also combine them—for example, n8n can call a Dify app through its API.
The fastest way to get started with Dify is through the One-Click Apps on your VPS. The app starts all services in the correct order, is directly accessible over HTTPS with a domain, and automatically generates all internal passwords and keys. You don’t need to set up a reverse proxy, certificate, or firewall rules.
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set Up One-Click Apps for instructions.
- At least 4 GB of RAM and 2 vCPU cores, as specified in the official documentation. 8 GB of RAM is recommended if you use knowledge bases with many documents or run other apps on the same server.
- Around 11 GB of free storage just for the service images, plus space for your documents and databases.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search for Dify in the app catalog and click Install app.
- Use a custom subdomain or zap.cloud is already selected, with a random name. Leave the option enabled or enter a name of your choice, such as
aiordify. - You don’t need to fill in anything under App configuration. All fields have default values, and the app generates the passwords itself. If you want Dify to send emails (invitations, password reset), enter the values for
MAIL_TYPE(smtp),SMTP_SERVER,SMTP_PORT,SMTP_USERNAME,SMTP_PASSWORD, andMAIL_DEFAULT_SEND_FROMhere. You can also do this later. - Click Queue installation.
The first time, the VPS downloads the images for all services, several gigabytes in total. Depending on your connection, installation may take a few minutes. Dify then creates its database the first time it starts. Until that’s done, the address will show an error page. Reload it after a short while.
Dify doesn’t create its admin account automatically. The first time you visit the address, you’ll be taken through the initial setup. To prevent someone else from creating the account before you, setup is protected by a password generated by the app during installation. The app card displays the message “Create admin account”; the Open initial setup button takes you directly to the right page.
- Click the gear icon on the app card and go to App environment.
- Under Automatically generated values, find
SERVICE_BASE64_24_INITPASSWORD. This is the 24-character password for the initial setup. Click the eye icon to reveal the value, or click the icon next to it to copy it. - Open your app using the Access link or Open initial setup. Dify displays the “Admin initialization password” field. Paste in the password and click Validate.
- On the next page, create the admin account with an email address, username, and your own password. Use these details to sign in from now on.
You only need the initial setup password until you create the first account. After that, /install is disabled and Dify only displays the login page. Additional people can only join by invitation.
In installations from before December 2026, the initial setup password was too long and Dify stopped with “HTTP 422.” An app update won’t fix this: reinstall the app under App actions by selecting Reinstall app, and check Also delete data volumes. You won’t lose anything because no apps could have been created without an admin account.
Dify separates workspaces and roles. To invite other people, go to Members in your account settings (your avatar in the top-right corner) and select a role, such as Admin, Editor, or Normal. Normal members can only use apps; editors can create their own apps.
If email sending isn’t set up, Dify displays an invitation link after you invite someone. Send the link to them yourself. If you add SMTP values under App configuration, Dify will send invitations and password reset emails itself. If you forget your own password and email sending isn’t set up, the only option is to run the flask reset-password command in the API container.
Update Dify in the app settings (gear icon) under App update. Click Check for updates and install a new version by clicking Apply update. If it says the app is up to date, there isn’t a newer version in the app catalog yet.
When a new version starts, Dify automatically updates its database. After that, you can only go back to the old version by restoring a backup. So back up the VPS first, for example, through Backups in the dashboard, and read the new version’s release notes.
Your apps, accounts, conversation histories, and settings are stored in the PostgreSQL database, uploaded documents are stored in the storage volume, and knowledge base content is stored in Weaviate. All volumes are preserved during updates.
The rest of this guide describes a manual installation of Dify with Docker Compose on your VPS—for example, if you don’t use One-Click Apps on your server or want to run Dify behind your own reverse proxy. Dify provides a ready-made Compose configuration in its GitHub repository that you only need to adjust.
- A Linux VPS with Debian or Ubuntu and SSH access. See First Access via SSH.
- Docker and Docker Compose version 2.35 or later. See Install Docker. Check the versions with
docker --versionanddocker compose version. Older Compose versions read the settings in the wrong order. - Git, which you can install with
apt install git. - A domain or subdomain whose A record points to your VPS IP address (e.g.
dify.example.com).
The values below apply to Dify with the default services (PostgreSQL, Redis, Weaviate). The official documentation specifies at least 2 CPU cores and 4 GB of RAM.
| Hardware | Minimum | Recommended |
|---|---|---|
| CPU | 2 vCPU cores | 4 vCPU cores |
| RAM | 4 GB | 8 GB |
| Storage | 30 GB | 50 GB |
By default, Dify’s Compose configuration publishes ports 80 and 443 (nginx) and 5003 (plugin debugging) on all network interfaces. In this guide, you’ll bind nginx to 127.0.0.1:8080 instead and omit port 5003 entirely. Only SSH and your reverse proxy will then be accessible from outside:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Ports published by Docker are accessible from outside even if ufw blocks them. Docker adds its own rules before those of ufw. That’s why you’ll adjust the ports below in a separate file instead of relying on ufw. For more about firewalls, see Firewall Management on Linux.
Download the Compose configuration for the version you want. This example uses version 1.19.0; you can find the current version on the release page:
cd /opt
git clone --branch 1.19.0 --depth 1 https://github.com/langgenius/dify.git
cd /opt/dify/docker
cp .env.example .env
chmod 600 .env
The .env file needs a random key for the agent sandbox. You’ll also add a password for the initial setup and the public address of your installation. The commands write the random values directly to the file without displaying them. Replace dify.example.com with your domain:
sed -i "s/^DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN=.*/DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN=$(openssl rand -hex 32)/" .env
echo "INIT_PASSWORD=$(openssl rand -hex 12)" >> .env
echo "FILES_URL=https://dify.example.com" >> .env
echo "TRIGGER_URL=https://dify.example.com" >> .env
Next, create the docker-compose.override.yaml file, for example with nano docker-compose.override.yaml. Docker Compose automatically reads it in addition to the supplied file:
services:
nginx:
ports: !override
- "127.0.0.1:8080:80"
plugin_daemon:
ports: !reset []
Here’s what the key settings do:
DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN: A shared key between the agent service and its sandbox. Dify won’t start completely without it.INIT_PASSWORD: Anyone accessing the initial setup must enter this password first. This prevents someone else from creating the admin account before you. Dify allows a maximum of 30 characters.FILES_URLandTRIGGER_URL: The public address Dify uses to create links to files and webhook URLs.ports: !override: nginx is only accessible from the server itself, and from outside only through your reverse proxy. Port443is omitted because the reverse proxy handles HTTPS.ports: !reset []: The plugin service doesn’t publish a port. You only need port5003if you develop plugins yourself.
Dify uses the supplied default values for everything else. COMPOSE_PROFILES=weaviate,postgresql,collaboration in .env selects PostgreSQL, Weaviate, and the WebSocket service. Start Dify:
docker compose up -d
docker compose ps --all
The first time it starts, Docker downloads several gigabytes of images. Dify is ready when all services are running and the health checks show healthy. The init_permissions service exits with code 0 after startup; that’s expected.
First set up the reverse proxy in the next section, then open https://dify.example.com/install. Dify will first ask for the initial setup password. Display it on the server with grep INIT_PASSWORD /opt/dify/docker/.env. Then, as described above for the easy setup, create the admin account with an email address, username, and password.
For a quick test without a domain, you can also use an SSH tunnel: ssh -L 8080:127.0.0.1:8080 root@SERVER_IP. As long as the tunnel is open, you can access Dify on your computer at http://localhost:8080/install.
To access Dify from outside, set up a reverse proxy with a valid certificate in front of it. For the basics, see Set Up a Reverse Proxy with nginx and Create an SSL Certificate (Let's Encrypt). Here’s a server block for nginx on the VPS:
server {
listen 80;
server_name dify.example.com;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
proxy_read_timeout 3600s;
}
}
Then get the certificate with certbot --nginx -d dify.example.com. Certbot adds HTTPS and HTTP redirection to the block. proxy_buffering off and the long timeout ensure that streamed model responses arrive immediately and long workflows don’t get interrupted. client_max_body_size allows uploads of up to 100 MB, which is also the limit for the nginx in Dify.
For more tips on securing your server, see Linux Security Tips.
Dify stores all data in subfolders of /opt/dify/docker/volumes: the PostgreSQL database, uploaded files, knowledge base content in Weaviate, and installed plugins. To create a consistent backup, briefly stop Dify and archive the folder along with your configuration:
cd /opt/dify/docker
docker compose stop
tar -czf /root/dify-backup-$(date +%F).tar.gz volumes .env docker-compose.override.yaml
docker compose start
Don’t store the backup only on the VPS itself. It contains your model provider API keys in encrypted form, and the key for them is also in the volumes folder.
Back up first as described above and read the release notes. Then get the new version, for example 1.20.0, and restart Dify:
cd /opt/dify/docker
git fetch --depth 1 origin tag 1.20.0
git checkout 1.20.0
docker compose pull
docker compose up -d
Your .env and docker-compose.override.yaml files and the volumes folder aren’t part of the repository and will be preserved. The new version’s .env.example file lists any new required values. Run bash dify-env-sync.sh to add new entries to your .env without overwriting your values. Dify automatically updates the database when it starts.
After setup, connect a model provider. Without one, Dify can’t generate a single response. Then build your first app and give it a knowledge base.
Model providers are plugins in Dify. Install them once from the Dify Marketplace, then enter your access details:
- Click your avatar in the top-right corner, then click Settings and select Model Provider.
- Install the provider you want to use, such as OpenAI, Anthropic, or Ollama. For any service with an OpenAI-compatible API, there’s OpenAI-API-compatible.
- Enter your API key for the provider and save it. Dify checks the connection immediately.
- Under System Model Settings, choose which model Dify uses by default for chats and which it uses as the embedding model for knowledge bases.
Here’s how to connect your own models on your server:
- LiteLLM: LiteLLM brings many providers, including Ollama, together behind an OpenAI-compatible address with its own keys and budgets. In Dify, select OpenAI-API-compatible, enter
https://llm.example.com/v1as the address, a virtual key from LiteLLM as the API key, and the public model name from LiteLLM as the model name. This is the most convenient option if multiple apps need to use the same models. - Ollama: The Ollama plugin needs the Ollama API address (port
11434), the model name such asllama3.2:3b, and the model type (LLM or Text Embedding). The Ollama API doesn’t require authentication and must never be exposed to the internet. With the Ollama One-Click App, it isn’t accessible from outside at all. So put LiteLLM in front of Ollama and connect Dify to LiteLLM as described above.
Dify downloads plugins and their Python packages from the Marketplace and PyPI during installation. This can take a few minutes the first time. Your VPS needs an internet connection to do this.
Build apps in the Studio section. Click Create from Blank and select an app type:
| App type | What it’s for |
|---|---|
| Chatbot | A simple chat with system instructions and an optional knowledge base |
| Agent | A chat where the model calls tools itself, such as web search or custom APIs |
| Chatflow | A chat with a multi-step workflow in the visual editor |
| Workflow | A non-chat workflow that processes input and returns a result, for example, through an API |
A Chatbot is a good place to start: enter a name, select the model in the top-right corner, and write instructions under “Instructions” explaining how the bot should behave. You can test its responses immediately on the right. Click Publish to make the app available. You can then open it as a standalone web app, embed it on your website using a code snippet, or call it with an API key from the API Access section.
In a Workflow, connect components such as LLM, knowledge retrieval, conditions, HTTP requests, and code using drag and drop. Each step displays its inputs and outputs during testing, making it easy to find errors. Code steps in Python or JavaScript run in the app’s sandbox.
A knowledge base lets your app answer questions based on your own documents:
- Go to Knowledge and click Create Knowledge.
- Upload your files, such as PDFs, Word documents, Markdown, or text files.
- Leave the settings for splitting content into chunks at their defaults to start. Select High Quality for indexing if you’ve set up an embedding model. Economical works without an embedding model, but only finds relevant content through keywords.
- Click Save & Process. Dify splits the documents, calculates the vectors, and stores them in Weaviate.
- Open your chatbot app and add the knowledge base under Knowledge in the “Context” section.
When someone asks a question, Dify first searches for relevant sections and provides them to the model. Under Retrieval Testing in the knowledge base, you can check which sections Dify finds for a question. This is helpful if the answers are off the mark.
- Resources: Dify starts more than a dozen containers. The server will already be under heavy load with 4 GB of RAM. Large knowledge bases and many concurrent users need more.
- No built-in models: Dify only calls models. To run your own models, you need a model server such as Ollama, which can only respond to smaller models in a reasonable time on a VPS without a graphics card.
- Sandbox has fixed limits: Code steps in workflows run in an isolated sandbox with a time limit. Dify’s proxy deliberately blocks access to the internal network and other containers. Dify downloads plugins and Python packages from the internet.
- Provider costs: Every response and every document processed with an embedding model costs tokens with the provider. Keep an eye on usage under Monitoring in your apps.
You’ve set up Dify on your VPS, connected a model provider, built your first app, and given it a knowledge base. You now have your own platform for chatbots, agents, and AI workflows, with data stored on your server.
Prefer not to handle Docker manually? Use the easy option, the One-Click App, as described above under “The Easy Way: Dify as a One-Click App.”
