Before we jump into installing Dify, let’s get familiar with the main technologies that make it work. Think of them as the essential ingredients that, when combined, bring your Dify platform to life.
What are Large Language Models (LLMs)?
Large Language Models, or LLMs, are smart AI systems. They’ve been trained on huge amounts of text, which allows them to understand, create, and work with human language very well.
- How LLMs Work: Many LLMs figure out what word comes next in a sentence. This helps them do things like write text, translate languages, summarize information, and answer questions.
- Dify and LLMs: Dify itself isn’t an LLM. Instead, it’s a platform that helps you build and manage apps that use the power of different LLMs. Dify provides the tools to connect these LLMs to your data and ideas.
- Teamwork: LLMs offer the brainpower, while Dify provides the tools (like LLMOps for managing AI operations and BaaS for backend services) to turn that brainpower into useful, real-world applications. Dify handles a lot of the complex engineering behind the scenes.
What is Docker? (Images & Containers Explained)
Docker is a popular tool that uses a technology called “OS-level virtualization.” This basically means it can package software into neat little boxes called containers.
- Docker Images (The Recipe):
- Think of a Docker Image as a blueprint or a recipe. It’s a read-only file that has everything an application needs to run: the app’s code, tools like Python or Node.js, system libraries, and settings.
- An image is static – it doesn’t change, just like a written recipe.
- Docker Containers (The Cake):
- A Docker Container is a live, running version of a Docker Image. When you “run” an image, it becomes a container – the actual software doing its job on your computer.
- So, if the image is the recipe, the container is the cake you baked from that recipe.
- Why Use Docker?
- Consistency: Your app runs the same way everywhere (your laptop, a server, etc.).
- Isolation: Containers run separately from each other and the main computer, preventing conflicts.
- Efficiency: Containers are usually lighter and faster than traditional virtual machines.
- Dify and Docker: Dify is delivered as a set of Docker images for its different parts.
What is Docker Compose?
Modern apps, like Dify, are often made of many connected parts (services). For example, Dify has a web interface, an API, a database, and more. Docker Compose is a tool made to define and run these multi-container applications easily.
- The
docker-compose.yml
File: Docker Compose uses a special configuration file, usually nameddocker-compose.yml
. This file tells Docker Compose about all the services your app needs, how they connect (networks), and where they store data (volumes). - Simple Commands: With Docker Compose, you can start or stop your entire complex application with simple commands (like
docker compose up
). This makes sure your app runs consistently, whether you’re developing, testing, or running it live. - Key Benefits: It simplifies managing how services depend on each other, how they talk to each other, and how data is saved.
- Dify’s Architecture: Docker and Docker Compose are essential to Dify. They allow Dify to be a self-hostable, modular (made of distinct parts), and scalable (can grow to handle more users) platform. This container-based approach means Dify’s different components can be managed, updated, and scaled independently while still working together smoothly.
Prerequisites: What You Need to Install Dify on Ubuntu
Before you start installing Dify, make sure your Ubuntu server has the right setup. This is key for a smooth installation.
System Requirements:
- Ubuntu Server: It’s best to use a supported LTS (Long-Term Support) version of Ubuntu Server. Good choices are Ubuntu 20.04 LTS or Ubuntu 22.04 LTS, or newer versions.
- Hardware:
- CPU: You need at least 2 CPU Cores.
- RAM (Memory): The official minimum is 4 GiB. However, Dify has several parts (API, worker, web, database, Redis, a vector database like Weaviate, etc.). LLM apps also tend to use a good amount of memory. For smoother operation, especially for development or light use, at least 8 GiB of RAM is recommended. For busy production systems or when using multiple LLMs, 16GB or more might be needed.
- Disk Space: You should have at least 50GB of free disk space. This is for the Ubuntu operating system, Docker images, Dify’s data (database, user files, vector search indexes), and system logs.
Software Requirements:
- Docker Engine: Dify runs in Docker containers, so you need Docker Engine on your Ubuntu server.
- Version: 19.03 or later.
How to Install Docker Engine on Ubuntu:
1. Update your package list:
sudo apt update
2. Install necessary packages to allow apt
to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
3. Add Docker’s official GPG key (a security measure):
curl -fsSL [https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg) | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. Set up the stable Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] [https://download.docker.com/linux/ubuntu](https://download.docker.com/linux/ubuntu) $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Install Docker Engine, CLI, containerd, and plugins:
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
(Optional but Recommended) Add your user to the docker
group to run Docker commands without sudo
. You’ll need to log out and back in or reboot for this to take effect.
sudo usermod -aG docker ${USER}
6. Check your Docker version:
docker --version
Docker Compose: This tool helps manage Dify’s multiple containers.
Version: Docker Compose V2 (uses docker compose
command) is recommended. If you’re using V1 (uses docker-compose
command), you need version 1.28 or later. If you installed docker-compose-plugin
with Docker Engine (as shown above), you should have V2.
Check your Docker Compose version:
docker compose version
Essential Linux Command-Line Tools:
- Git: Needed to download (clone) the Dify source code.
Install with:sudo apt install git -y
- Curl (Optional, but often useful): A tool for transferring data using URLs. If not installed during Docker setup:
Install with:sudo apt install curl -y
- Text Editor: You’ll need a command-line text editor like
nano
(easy for beginners) orvim
to edit configuration files.
Installnano
with:sudo apt install nano -y
- User Privileges: You need access to an account that can use
sudo
. This is for installing software and managing Docker.
Prerequisites Checklist Table:
Category | Requirement | Check Command / Notes |
---|---|---|
Operating System | Ubuntu Server (e.g., 20.04 LTS, 22.04 LTS+) | lsb_release -a |
CPU | >= 2 Cores | nproc |
RAM | >= 4 GiB (8GiB+ recommended) | free -h |
Disk Space | >= 50 GB free | df -h |
Docker Engine | Version 19.03+ | docker --version |
Docker Compose | V2 recommended (or V1: 1.28+) | docker compose version |
Git | Installed | git --version |
Curl (Optional) | Installed | curl --version |
Text Editor | Installed (e.g., nano ) | nano --version (or check if nano command works) |
User Privileges | sudo access | User should be able to run commands starting with sudo . |
Making sure you have these prerequisites will help your Dify installation go smoothly. Using Docker Compose V2 is the current best practice.
Step-by-Step: Installing Dify with Docker Compose on Ubuntu
Now that your server is ready, let’s install Dify. This involves getting the Dify code, setting up some configurations, understanding its parts, and starting it up.

1. Cloning the Dify GitHub Repository
Dify’s installation files, including the important docker-compose.yaml
and a sample configuration file (.env.example
), are on its official GitHub page.
- Open a terminal on your Ubuntu server.
- Download (clone) the Dify repository. It’s usually best to get a specific stable version (a “release tag”) for production. You can find the latest stable tag on the Dify GitHub releases page.
For example, if v1.3.1
is the latest stable release:
git clone https://github.com/langgenius/dify.git --branch v1.3.1
If you prefer the very latest development version (use this carefully for live systems):
it clone https://github.com/langgenius/dify.git
This command will download the Dify code into a new folder named dify.
2. Navigating to the Docker Directory
The Docker Compose files for Dify are in a specific subfolder.
Move into that directory:
cd dify/docker
This folder contains the docker-compose.yaml
file and the .env.example
file.
3. Understanding and Configuring Environment Variables (the .env
file)
Environment variables are settings that Dify uses. They are especially important for security (like passwords) and for settings specific to your server. Dify uses a file named .env
to manage these.
- Create your own environment file by copying the example:
cp .env.example .env
This creates an.env
file that you can now customize. - Open the
.env
file with a text editor (likenano .env
) and change the settings. Key.env
Variables to Configure:
The.env.example
file has many settings. Here are the most important ones to check and change for your first setup:SECRET_KEY
: This is critical for security. It’s used for things like signing session cookies and encrypting sensitive data.- You MUST change this to a strong, random value before you start Dify for the first time. A weak or compromised
SECRET_KEY
can lead to major security problems. If you lose this key and don’t have a backup, you might not be able to recover encrypted data.Generate a strong key with a command like:bash openssl rand -base64 42
Copy the output and paste it as the value forSECRET_KEY
in your.env
file.
INIT_PASSWORD
: This sets the first password for the Dify administrator account.- Set a strong password here. You might also want to change it through the Dify interface after your first login.
DB_USERNAME
: Username for the database (default is usuallypostgres
).DB_PASSWORD
: Password for the database user (default is oftendifyai123456
). Change this to a strong, unique password.DB_HOST
: Where the database service is running (default isdb
, which is its name indocker-compose.yaml
).DB_DATABASE
: Name of the database (default is usuallydify
).
REDIS_PASSWORD
: Password for the Redis service (default is oftendifyai123456
). Change this to a strong, unique password.
CONSOLE_API_URL
: Backend API URL for the admin console.CONSOLE_WEB_URL
: Frontend URL for the admin console (e.g.,http://your_server_ip
).APP_WEB_URL
: Frontend URL for the AI apps you build (e.g.,http://your_server_ip
).SERVICE_API_URL
: Base URL for service APIs.FILES_URL
: URL for file previews and downloads (e.g.,http://your_server_ip/files
).
VECTOR_STORE
: Which vector database to use (e.g.,weaviate
,qdrant
,milvus
). The default Dify setup often includes Weaviate.Related settings likeWEAVIATE_ENDPOINT
if you’re not using the default built-in service.
STORAGE_TYPE
: Where user files (like datasets) are stored (e.g.,local
,s3
for Amazon S3,azure-blob
).STORAGE_LOCAL_PATH
: IfSTORAGE_TYPE=local
, this is the path inside the container where files are stored (default isstorage
). This path is then linked to a folder on your server indocker-compose.yaml
.
MAIL_TYPE
,SMTP_SERVER
,SMTP_USERNAME
,SMTP_PASSWORD
are needed if Dify has to send emails (e.g., for user invites or password resets).- You MUST change this to a strong, random value before you start Dify for the first time. A weak or compromised
Quick Table: Essential .env
Variables for First Setup
Variable Name | Default (from example) | Recommended Action / Description |
---|---|---|
SECRET_KEY | (Example key) | Critical: Change to a unique, strong random string. |
INIT_PASSWORD | (Example password) | Change to a strong initial admin password. |
DB_PASSWORD | difyai123456 | Critical: Change to a strong, unique password for PostgreSQL. |
REDIS_PASSWORD | difyai123456 | Critical: Change to a strong, unique password for Redis. |
CONSOLE_WEB_URL | '' | Set to http://your_server_ip or your domain. |
APP_WEB_URL | '' | Set to http://your_server_ip or your domain. |
FILES_URL | '' | Set to http://your_server_ip/files or domain equivalent. |
VECTOR_STORE | weaviate | Review if different vector store needed. Default setup usually brings Weaviate. |
STORAGE_TYPE | local | Review if external storage needed. For local , ensure volume permissions. |
4. Understanding Dify’s docker-compose.yaml
File
The docker-compose.yaml
file is like the master plan for your Dify deployment. It defines all the services Dify needs, how they are configured, how they connect to each other (networks), and where they store data (volumes). You usually don’t need to edit this file directly for a standard setup (most changes are made in the .env
file), but knowing its structure is helpful for troubleshooting or advanced setups.
Overview of Dify’s Core Services:
Dify uses a “microservices” approach, meaning it’s made of several smaller, independent services working together. Key services typically defined in docker-compose.yaml
include:
api
: The main backend service. It’s built with Python/Flask and provides the RESTful APIs that power Dify.worker
: A background worker service (based on Celery). It handles tasks that take time, like processing datasets or indexing documents for search.web
: The frontend application, built with Next.js. This serves the user interface for the Dify admin console and the AI apps you create.db
: A PostgreSQL database. This is where Dify stores most of its data, like user info, app settings, and knowledge base content.redis
: A Redis instance. It’s used for caching (storing frequently used data to speed things up) and as a message system between theapi
andworker
services.nginx
: A web server that acts as a “reverse proxy.” It directs incoming web traffic to the correct backend (api
) or frontend (web
) service. It can also handle SSL for secure HTTPS connections.weaviate
/qdrant
/ etc. (Vector Database): A special database for storing and searching “vector embeddings.” These are crucial for Dify’s RAG (Retrieval-Augmented Generation) feature, which lets AI answer questions based on your documents. Dify’sdocker-compose.yaml
might use “profiles” to let you choose different vector databases. For example, to use Qdrant instead of Weaviate, you might start Docker Compose with a specific profile (e.g.,docker compose --profile qdrant up -d
).sandbox
: A secure environment for running code, like Python tools used by Dify’s “Agents.” This helps isolate code that might not be fully trusted.plugin_daemon
: Manages Dify plugins, which can add more features to the platform.ssrf_proxy
: This service acts as a controlled gateway for outgoing web requests made by Dify (e.g., when Dify needs to access external tools or websites). It helps prevent a type of attack called Server-Side Request Forgery (SSRF) by making sure Dify only connects to approved destinations. This is an important security feature.
Quick Table: Key Dify Services in docker-compose.yaml
Service Name | Brief Description & Key Technologies |
---|---|
api | Main backend (Python/Flask); serves RESTful APIs. |
worker | Background task processor (Celery); handles async jobs. |
web | Frontend application (Next.js); provides the UI. |
db | PostgreSQL database; stores persistent application data. |
redis | In-memory store; caching and message broker. |
nginx | Reverse proxy & web server; routes traffic, handles SSL. |
weaviate (default) | Vector database; stores & searches embeddings for RAG. |
sandbox | Secure code execution environment for Dify Agents. |
plugin_daemon | Manages and executes Dify plugins. |
ssrf_proxy | Outbound request proxy (Squid-based); enhances security. |
How Data is Saved (Volumes):
Docker containers are temporary by default. If a container is removed, any data inside it is lost. To save data permanently, Docker uses volumes. Dify’s docker-compose.yaml
sets up volumes for services like db
(PostgreSQL data), redis
(if set to save data), weaviate
(vector search indexes), and for local file storage if STORAGE_TYPE=local
(e.g., files are mapped to a ./volumes/app/storage
folder on your server). These volumes ensure your important data isn’t lost when containers restart or are updated. The ./volumes/
path is usually relative to where your docker-compose.yaml
file is.
How Services Talk to Each Other (Docker Networks):
Docker Compose automatically creates a default network for all the services defined in docker-compose.yaml
. This lets services find and communicate with each other using their service names as hostnames (e.g., the api
service can connect to the db
service by using the hostname db
). Dify’s setup also defines specific networks like ssrf_proxy_network
to isolate certain communications for better security (e.g., forcing some outgoing traffic through the ssrf_proxy
service).
5. Starting Dify Services
Once your .env
file is configured, you can start all the Dify services.
In the dify/docker
directory, run:
docker compose up -d
docker compose up
: This command reads yourdocker-compose.yaml
and.env
files, then creates and starts all the defined services.-d
: This flag runs the containers in “detached mode,” meaning they run in the background, and you get your terminal back.
Docker will first download any images it doesn’t have locally. Then, it will create the containers, networks, and volumes. You’ll see output showing the status of each service as it starts. A typical Dify setup might start around 10-12 containers.
6. Verifying the Installation
After running docker compose up -d
, check if all services started correctly:
- Check container status:
docker compose ps
This command lists all containers that are part of your Dify application. TheirSTATUS
should ideally berunning
orUp
. - Check logs for errors, especially for key services:
bash docker compose logs -f web docker compose logs -f api docker compose logs -f worker
- The
-f
flag “follows” the log output, showing new messages as they appear. PressCtrl+C
to stop following. - Look for any error messages that might show problems during startup. The
docker compose logs
command is your main tool for troubleshooting.
- The
If all containers are running and there are no critical errors in the logs, your Dify installation should be successful!
Post-Installation: Accessing and Initializing Dify
Once Dify’s services are running in Docker, the next step is to access its web interface and do the initial administrator setup.

Accessing the Dify Web Interface
Dify’s web interface is usually served by the nginx
service, which directs traffic to the web
(frontend) and api
(backend) services.
- If Dify is running on your local Ubuntu machine (e.g., a desktop):
- Open a web browser and go to
http://localhost/install
orhttp://localhost
. - The port is usually 80 for HTTP, handled by Nginx.
- Open a web browser and go to
- If Dify is running on a remote Ubuntu server:
- Replace
localhost
with your server’s public or private IP address:http://your_server_ip/install
orhttp://your_server_ip
. - Make sure any firewalls (like
ufw
on Ubuntu or cloud provider security groups) allow incoming traffic on port 80 (for HTTP) and/or 443 (for HTTPS, if you set up SSL later).
- Replace
The /install
path is specifically for the first-time administrator setup. This is a one-time process. If you try to access it after the initial setup, you might be redirected to the login page or see an error, which is normal.
Initial Administrator Account Setup
When you access the /install
URL for the first time, Dify will show you an administrator account setup page.
- This page usually asks you to set an email address and a password for the main administrator account.
- If you set the
INIT_PASSWORD
variable in your.env
file, Dify might use this as the initial password or ask for it. Regardless, it’s a good security practice to set a unique, strong password here or change it immediately after your first login through the Dify user interface. - Follow the on-screen instructions to complete the setup.
A Quick Tour of the Dify Dashboard
After you log in with your new administrator details, you’ll see the Dify dashboard. Here’s a brief look at the main sections:
- Studio: This is where you create and configure AI applications (like Chatbots, Agents, and Workflows).
- Knowledge: Manage your knowledge bases here. You can upload documents (PDFs, TXT, etc.) that Dify will use for RAG (Retrieval-Augmented Generation) to answer questions based on your custom data.
- Tools: Lists available built-in tools and lets you add custom tools that your AI Agents can use.
- Model Providers: Configure connections to various LLMs (e.g., OpenAI, Anthropic, Hugging Face, or models you host yourself).
- Settings: Contains workspace settings, user management, API keys, and other admin configurations.
If you can reach the dashboard and see these sections, Dify is installed and working!
Managing Your Self-Hosted Dify Instance
Once Dify is up and running, you’ll need to perform ongoing management tasks like stopping, starting, updating, and backing up your instance. Docker Compose provides commands for most of these.
Common Docker Compose Commands for Dify Management
Command | Description |
---|---|
docker compose up -d | Starts all Dify services in the background. Creates containers/networks/volumes if they don’t exist. |
docker compose down | Stops and removes all Dify containers and networks. Named volumes (your data) are kept by default. |
docker compose down --volumes | Stops and removes containers, networks, AND named volumes. Use with CAUTION as this deletes data. |
docker compose ps | Lists the status of all containers in your Dify application. |
docker compose logs <service_name> | Shows logs for a specific service (e.g., api , web , db ). Add -f to follow logs live. |
docker compose logs | Shows combined logs from all services. Add -f to follow live. |
docker compose pull | Downloads the latest images for all services (as defined in docker-compose.yaml ). Used for updates. |
docker compose exec <service_name> <command> | Runs a command inside a running container (e.g., docker compose exec api flask db upgrade ). |
docker compose restart <service_name> | Restarts a specific service. |
docker compose stop <service_name> | Stops a specific service without removing its container. |
docker compose start <service_name> | Starts a previously stopped service. |
Stopping and Starting Dify Services
- To stop all Dify services: Navigate to your
dify/docker
directory and run:docker compose down
This stops and removes the containers. By default, it does not delete your data stored in named volumes. - To start all Dify services: Navigate to your
dify/docker
directory and run:
docker compose up -d
This will recreate and start the containers.
Updating Dify to the Latest Version
Updating Dify involves getting the latest code and Docker images, then restarting the services. Always back up your data before any major update.
Here’s the general process:
- (Highly Recommended) Back up your Dify data (see the next subsection).
- Navigate to the main directory of your cloned Dify repository (e.g.,
cd ../
if you are indify/docker
). - Get the latest changes from the Dify GitHub repository. If you cloned a specific version, make sure you update from the correct source:
git pull origin main # Or the specific branch/tag you are using
To update to a specific new version tag (e.g., v1.3.2
):
git fetch --all --tags git checkout tags/v1.3.2 -b temp_v1.3.2 # Creates a temporary local branch for the tag
- Navigate back to the Docker directory:
cd docker
. - Stop the currently running Dify services:
docker compose down
- Download the latest Docker images (which might have been updated in the
docker-compose.yaml
you just pulled):docker compose pull
- CRUCIAL STEP: Synchronize Your
.env
File. This is a common place where updates can go wrong. New Dify versions might add new important settings or change existing ones.- Compare your current
.env
file with the.env.example
file (which was updated bygit pull
). - Manually add any new settings from
.env.example
to your.env
file and update any values if needed. If you miss this, the updated Dify might not work correctly.
- Compare your current
- Start Dify with the new images and configurations:
docker compose up -d
- Database Migrations: Dify updates often include changes to the database structure. The
api
service usually tries to run these migrations automatically when it starts. However, it’s good to be aware of this. If you have problems, or if automatic migration is turned off, you can run them manually:docker compose exec api flask db upgrade
Always check Dify’s official release notes for any specific instructions about updates or database migrations.
Backing Up Dify Data (Focus on Docker Volumes)
Regular backups are essential for any application you host yourself. For Dify, your critical data includes:
- The PostgreSQL database (user accounts, app settings, knowledge base info, etc.).
- Locally stored files (if
STORAGE_TYPE=local
is used for datasets, uploaded documents). - Vector database indexes (e.g., Weaviate or Qdrant data).
Dify’s docker-compose.yaml
usually maps these data stores to subdirectories inside a ./volumes/
folder (located in dify/docker/volumes/
). This makes backups simpler because you can archive this single volumes
directory.
Recommended Backup Strategy for Local Volumes:
- Stop the Dify services to make sure data is consistent (not being written to):
docker compose down
- Navigate to the
dify/docker
directory (if you’re not already there). - Create a compressed archive (a
.tar.gz
file) of the entirevolumes
directory. The command below includes the current date and time in the filename:tar -czvf dify_backup_$(date +%Y%m%d_%H%M%S).tar.gz ./volumes/
- Move the created
dify_backup_*.tar.gz
file to a secure, separate backup location (e.g., another server, cloud storage).
Restoring from Backup:
- Make sure Dify services are stopped (
docker compose down
). - If you have an existing
./volumes/
directory, remove or rename it. - Copy your backup archive (e.g.,
dify_backup_YYYYMMDD_HHMMSS.tar.gz
) into thedify/docker/
directory. - Extract the archive:
tar -xzvf dify_backup_YYYYMMDD_HHMMSS.tar.gz
This should recreate the./volumes/
directory with your backed-up data. - Start Dify services:
docker compose up -d
.
Customizing Dify through .env
and Restarting
If you make changes to your dify/docker/.env
file, you need to restart Dify for those changes to take effect:
docker compose down && docker compose up -d
This command first stops and removes the current containers, then starts them again with the new .env
settings.
Troubleshooting Common Installation Issues
Even if you prepare carefully, you might run into issues during installation. Here are some common problems and how to fix them.
General Docker Troubleshooting Steps:
- Container Start-up Failures:
- Check Logs First: This is the most important step. Use
docker compose logs <service_name>
(e.g.,docker compose logs api
ordocker compose logs db
) to see the output from the failing service. Error messages often tell you what’s wrong.docker compose logs
(without a service name) shows combined logs from all services. - Not Enough Resources: If your server doesn’t have enough CPU or RAM, containers might fail to start or crash soon after. Check your system resources with tools like
top
orhtop
.
- Check Logs First: This is the most important step. Use
- Image Pulling Issues (Can’t Download Images):
- Make sure your server has internet access.
- Check that the image names and tags in
docker-compose.yaml
are correct (unlikely if you’re using official Dify files, but possible if you edited them). - Check the status of Docker Hub if images are failing to download from there.
- Port Conflicts: This happens if a port Dify wants to use (like port 80 for Nginx) is already being used by another service on your server.
- To find out which process is using a specific port (e.g., port 80):
sudo ss -tulnp | grep ':80'
- Solution: Either stop the other service if it’s not essential, or change the port Dify uses. For Nginx in Dify, you can often do this by setting a variable like
EXPOSE_NGINX_PORT
in your.env
file to a different host port (e.g.,EXPOSE_NGINX_PORT=8080
). Then you would access Dify viahttp://your_server_ip:8080
.
- To find out which process is using a specific port (e.g., port 80):
Dify-Specific Troubleshooting:
Many Dify-specific problems are related to incorrect settings in the .env
file, especially URLs, database passwords, or connections to external services. Always double-check your .env
file against the .env.example
and your server setup.
- Incorrect Password After Setup / Cannot Log In:
- If you forget the admin password or it’s incorrect, you can reset it using a command run inside the
api
container. First, find the exact name of yourapi
container (it might bedocker-api-1
or similar) usingdocker compose ps
. - Then run:
docker compose exec <dify_api_container_name> flask reset-password
. Follow the prompts.
- If you forget the admin password or it’s incorrect, you can reset it using a command run inside the
- “Error Decrypting API Key” or Encryption Key Issues:
- This can happen if you changed the
SECRET_KEY
in.env
after the initial setup, or if theapi/storage/privkeys
directory (which might be part of a volume) was lost or damaged. - To reset the encryption key pair:
docker compose exec <dify_api_container_name> flask reset-encrypt-key-pair
. - Caution: This might make previously encrypted data (like LLM API keys you stored in Dify) inaccessible, and you’ll need to re-enter them.
- This can happen if you changed the
- Domain/URL Configuration Issues:
- If Dify isn’t accessible via a domain name you set up, or if links inside Dify (like file previews) are broken, check the URL settings in your
.env
file. These includeCONSOLE_API_URL
,CONSOLE_WEB_URL
,APP_WEB_URL
,SERVICE_API_URL
,FILES_URL
. Make sure they correctly match your server’s IP address or domain name, includinghttp
orhttps
.
- If Dify isn’t accessible via a domain name you set up, or if links inside Dify (like file previews) are broken, check the URL settings in your
- Plugin Installation Failures:
- Error:
PluginDaemonBadRequestError: plugin_unique_identifier is not valid
.- Solution: This usually means the
author
field in the plugin’smanifest.yaml
file needs to be set correctly (often to your GitHub ID) before you package and install the plugin.
- Solution: This usually means the
- Error:
plugin verification has been enabled, and the plugin you want to install has a bad signature
.- Solution: For development or custom plugins you trust, you can temporarily disable signature verification. Add
FORCE_VERIFYING_SIGNATURE=false
to your.env
file and restart Dify (docker compose down && docker compose up -d
). - Caution: Only install plugins from sources you trust, especially if you disable signature verification.
- Solution: For development or custom plugins you trust, you can temporarily disable signature verification. Add
- Error:
- Database Migration Issues (Often During Updates):
- If Dify fails to start correctly after an update, and the logs for the
api
orworker
service show database errors (like “no such table” or “column undefined”), a database migration might have failed or been skipped. - Manually trigger migrations:
docker compose exec <dify_api_container_name> flask db upgrade
.
- If Dify fails to start correctly after an update, and the logs for the
- File Upload Failures:
- Check the
STORAGE_TYPE
and related settings (credentials, paths) in your.env
file. - If using local storage, make sure the host directory mapped as a volume (e.g.,
./volumes/app/storage
) has the correct write permissions for the user running the Docker containers. - If using cloud storage (S3, Azure Blob, etc.), verify bucket names, access keys, secret keys, and bucket permissions (Dify needs write access).
- Check the
- Accessing Local Models (e.g., Ollama) from Dockerized Dify:
- If you’re running an LLM directly on your Ubuntu host (not in Docker) and Dify needs to access it, using
127.0.0.1
orlocalhost
in Dify’s model provider settings won’t work. Inside a Docker container,127.0.0.1
refers to the container itself. - Solution: Use your host machine’s actual network IP address (e.g.,
192.168.1.100
). For Docker Desktop on macOS/Windows,host.docker.internal
can be used. For Linux, using the host’s network IP is more reliable. Make sure your locally hosted model is set up to listen on an interface that Docker can reach (e.g.,0.0.0.0
instead of just127.0.0.1
).
- If you’re running an LLM directly on your Ubuntu host (not in Docker) and Dify needs to access it, using
General Troubleshooting Flow:
- Check container status:
docker compose ps
. - Check for host-level issues: port conflicts, firewall rules.
- Inspect specific Dify service logs:
docker compose logs <service_name>
. - Review and verify your
.env
configurations carefully. - Use Dify-specific
flask
commands viadocker compose exec
if needed.
Conclusion: Unleash Your AI Potential with Self-Hosted Dify
Congratulations! By successfully installing Dify on your Ubuntu server using Docker Compose, you’ve taken a big step towards using a powerful, self-hosted platform for Large Language Model applications. This setup gives you complete control over your AI development environment, improving data privacy and allowing deep customization.
Now that Dify is running, it’s time to explore what it can do:
- Create Your First AI Application: Try building a simple chatbot or a text generation app in the “Studio.” This is a great way to get familiar with the interface and how to work with prompts.
- Connect Different LLMs: Experiment with various model providers. You can connect to commercial APIs or even self-hosted open-source models to see which ones work best for different tasks.
- Build a Knowledge Base: Upload your documents (PDFs, text files, etc.) into Dify’s “Knowledge” section. This enables Retrieval-Augmented Generation (RAG), allowing your AI applications to answer questions based on your own custom data.
- Experiment with Agents: Explore Dify’s agent capabilities to build AI assistants that can use tools and perform complex, multi-step reasoning.
For more advanced features, like using Dify’s APIs or developing custom plugins, the official Dify documentation is an excellent resource.
Dify also has a strong and active open-source community. You can connect with other users and developers on platforms like GitHub, forums, or Discord (if available). These communities are great for getting support, sharing what you’ve built, learning best practices, finding community-made plugins, and even contributing to the Dify project itself.
By self-hosting Dify, you’re not just deploying software; you’re gaining a dynamic and evolving toolkit for AI innovation. Enjoy exploring and building!