How to self-host Dify on your own server
About 30 minutes · Commands checked against the official documentation on November 19, 2026
Dify is an open-source platform for building AI agents and LLM apps. Its standard self-hosted deployment runs everything it needs, including the database and vector store, with one Docker Compose command.
This guide follows Dify's own Docker Compose quick start. You end with Dify running on your server and an administrator account.
Dify is #6 on the all-time Top 100 this week.
You will need
- A Linux server with at least 2 CPU cores and 4 GiB of memory (Dify's stated minimum)
- Ubuntu 24.04 LTS, with Git and OpenSSL (both are on standard Ubuntu server images)
- Comfort with SSH and a terminal
1.Get a server
Rent a virtual private server (VPS) running Ubuntu 24.04 LTS. Choose one with at least 2 CPU cores and 4 GiB of memory, which is Dify's stated minimum.
Any provider works. When it is created you will have an IP address and a way to log in over SSH, usually as root or as a user that can run sudo.
2.Install Docker
Log in to the server over SSH, then install Docker Engine and the Compose plugin from Docker's official repository:
# Add Docker's official GPG key: sudo apt update sudo apt install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: sudo tee /etc/apt/sources.list.d/docker.sources <<EOF Types: deb URIs: https://download.docker.com/linux/ubuntu Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") Components: stable Architectures: $(dpkg --print-architecture) Signed-By: /etc/apt/keyrings/docker.asc EOF sudo apt update # Install Docker: sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginCheck that both are available. If Docker isn't running, start it with sudo systemctl start docker.
3.Check Docker Compose
Dify needs Docker Compose 2.35.0 or later. Check the version:
docker compose version4.Download a Dify release
Pick the latest version from Dify's releases page (linked below) and clone it, replacing <version> with that tag. The latest release when this guide was checked was 1.20.0.
git clone --branch <version> --depth 1 https://github.com/langgenius/dify.git cd dify/docker5.Create the settings file
cp .env.example .env openssl rand -hex 32The second command prints a random token. Open .env and set DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN to it. The agent service and its sandbox need this shared token to start.
6.Start Dify and check the services
From the dify/docker folder, run (add sudo in front if your user isn't in the docker group):
docker compose up -d docker compose ps --allThe long-running services should show Up or healthy. The init_permissions task runs once and shows Exited (0) when it's done.
7.Create the administrator account
Open http://<your server's IP address>/install in a browser and create the administrator account, then sign in at http://<your server's IP address>.
Do this as soon as Dify is up. Until an administrator exists, anyone who reaches that address can create one.
Dify serves plain HTTP on port 80 by default. If port 80 is already in use, set EXPOSE_NGINX_PORT in .env to another port and add it to the address.
Before anyone else uses it
Dify's documentation says to configure HTTPS and replace the bundled development credentials in .env before others can reach the deployment: DB_PASSWORD and REDIS_PASSWORD; SANDBOX_API_KEY and CODE_EXECUTION_API_KEY (set to the same strong secret); the Weaviate API key settings; PLUGIN_DAEMON_KEY and PLUGIN_DIFY_INNER_API_KEY; and the agent tokens. Its "Secure the Deployment" section, linked below, lists each one. Leave SECRET_KEY as it is.
Apply changes with docker compose up -d, not docker compose restart, which keeps the old settings.
Updating
Read the upgrade notes for the target release first, back up .env and the docker/volumes folder, then follow Dify's Upgrade steps.
Sources
Every command above is taken from these pages. If a step has changed, they are the authority.