Host Your Own AI Agent with OpenClaw - Free 1-Click Setup!

How to Self-Host Dify on a VPS

Dify is an open-source platform for building LLM applications — a visual workflow editor, RAG pipeline, and agent builder in one interface. It self-hosts via Docker Compose on a standard VPS: clone the repo, copy the env file, run docker compose up, and you have a working instance. Budget at least 2 vCPUs and 4 GB RAM, more if you plan to index large document sets for retrieval.

What Is Dify?

Dify is an open-source LLM application development platform that combines a visual workflow canvas, a built-in retrieval-augmented generation (RAG) pipeline, agent orchestration, and prompt management in a single tool. Instead of writing separate scripts to chain a document lookup, an LLM call, and a formatted response together, you build the pipeline visually and Dify handles the plumbing — vector indexing, model routing, and API exposure for whatever you build.

Why Self-Host Dify Instead of Dify Cloud?

  • Data privacy: documents, prompts, and API keys stay on your server instead of a vendor’s infrastructure.
  • No per-seat or per-credit pricing: your only recurring cost is the VPS itself.
  • Full model flexibility: connect any API-based model (OpenAI, Anthropic, DeepSeek) or a locally hosted model via Ollama.
  • GDPR-friendly: deploying on an EU-based VPS keeps document and prompt data inside the geographic boundaries many compliance regimes require.

VPS Requirements for Dify

VPS requirements for Dify: a minimum of 2 vCPUs and 2 GB RAM will run Dify, but 4–8 GB RAM and 2–4 vCPUs are recommended for production use, since embedding generation and vector storage for RAG scale with document volume.

Minimum vs. recommended VPS specs for self-hosting Dify
ComponentMinimumRecommended
vCPU22–4
RAM2 GB4–8 GB
Storage20 GB SSD/NVMe40 GB+ NVMe (scales with document volume)
Docker Composev2.24.0+Latest stable

Specs reflect Dify’s documented Docker Compose requirements; actual RAM usage scales with indexed document/embedding volume.

Dify runs as a multi-container stack — the web frontend, API backend, a worker process, Postgres, Redis, and a vector store (Weaviate by default, swappable for Milvus or others) all run alongside each other. That’s why it needs more headroom than a single-container tool: more RAM if you’re indexing large document sets for RAG, since embedding generation and vector storage are the heaviest parts of the stack.

How to Install Dify on a VPS with Docker Compose

  1. Provision a VPS meeting the specs above and update the system: sudo apt update && sudo apt upgrade -y
  2. Install Docker and the Docker Compose plugin (v2.24.0 or later — check with docker compose version)
  3. Clone the latest Dify release: git clone –branch “$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)” https://github.com/langgenius/dify.git
  4. Move into the docker directory: cd dify/docker
  5. Copy the example environment file: cp .env.example .env
  6. Edit .env to set your domain, secret key, and any model provider API keys you already have
  7. Start the stack: docker compose up -d
  8. Confirm every container shows Up or healthy: docker compose ps (an Exited status on init_permissions is expected and normal)
  9. Open http://your_server_ip/install in a browser to create the admin account
  10. Log in at http://your_server_ip and connect your first model provider
  11. Add a reverse proxy (Caddy or Nginx) with a Let’s Encrypt certificate to serve Dify over HTTPS before exposing it beyond local testing

Why Run Dify on a Contabo VPS

Dify’s multi-container footprint — Postgres, Redis, and a vector store running alongside the app — makes RAM the resource that matters most. A Cloud VPS 8 gives you 24 GB of RAM for 14 €/month, comfortable headroom for a production Dify instance with room to index a meaningful document set. If your RAG workload grows into large-scale embedding storage, the NVMe-backed Cloud VPS Performance line adds faster disk I/O for vector search at a similar RAM-per-Euro value. EU data centers keep the documents you’re indexing — and the prompts your users send — inside GDPR-friendly infrastructure.

FAQ: Self-Hosting Dify

How much RAM does Dify need to self-host?

2 GB is the documented minimum, but 4–8 GB is realistic for anything beyond a quick test — the multi-container stack (Postgres, Redis, vector store, worker) adds up quickly, and embedding generation for RAG document indexing is the heaviest part of the workload.

Is Dify free to self-host?

Yes, for internal and commercial use. Dify’s license is a modified Apache 2.0: you can run it commercially as a backend for your own applications without paying anything. The one restriction is operating it as a multi-tenant hosted service for other customers, which requires written permission from the maintainers.

Can I run Dify without a GPU?

Yes, as long as you’re calling an external model API (OpenAI, Anthropic, DeepSeek) rather than hosting the LLM yourself. A standard CPU-only VPS handles the orchestration, RAG pipeline, and vector search fine. A GPU is only needed if you also want to run the language model itself locally via Ollama or a similar tool.

Scroll to Top