Why Host Dify on a VPS?
Using the cloud version of Dify means entrusting your prompts, your business data and your API keys to a third-party server, with limits on the number of applications and models you can access. By self-hosting Dify on a VPS, you remove these constraints: no monthly usage-based subscription, no sensitive data sent outside, and the freedom to connect any model provider (OpenAI, Anthropic, Ollama locally, etc.). It is the ideal solution for teams that want to build robust AI pipelines in an environment under their full control.
What You Can Do With Dify
- Create custom chatbots and AI agents connected to your own data sources (RAG)
- Orchestrate multi-step workflows combining several language models and external tools
- Connect Dify to OpenAI, Anthropic Claude, Mistral, or a local model via Ollama
- Expose your AI applications via a REST API or an embeddable widget for your site
- Manage your team's access with a system of roles and workspaces
- Track usage logs, per-model costs and the performance of your pipelines
Prerequisites: Sizing Your VPS Correctly
Dify runs a fleet of Docker services in parallel: an API server, a Celery worker for embeddings and async jobs, the web frontend, PostgreSQL, Redis, Weaviate (vector store for RAG), a code-execution sandbox and an internal proxy.
Absolute minimum: 2 vCPU · 4 GB RAM · 40 GB SSD storage. With these specs Dify starts and lets you test basic features.
Recommended for real use: 4 vCPU · 8 GB RAM · 80 GB storage. As soon as you index large documents or multiple users query simultaneously, embedding generation and the vector store saturate 4 GB. The ServOrbit VPS-4 plan suits a team workload without a local model.
With a local model (Ollama): add the model's own footprint. A quantised Llama 3 8B (Q4) needs ~6 GB of VRAM or dedicated RAM. Plan for at least 16 GB RAM on the VPS to run Dify and Ollama side by side without swap.
Recommended OS: Ubuntu 22.04 LTS with Docker 24+ and Docker Compose v2.
Install Dify on Your ServOrbit VPS
Order a ServOrbit Cloud VPS
Go to the /vps-cloud page and choose a plan suited to your usage (minimum 2 vCPU / 4 GB RAM, recommended 4 vCPU / 8 GB). Select Ubuntu 22.04 LTS as the operating system, then complete the order. Your VPS is provisioned in under a minute.
Clone the repository and copy the configuration
Connect via SSH to your VPS, then run:
git clone https://github.com/langgenius/dify.git cd dify/docker cp .env.example .envThe
.envfile centralises all configuration variables (secret keys, URLs, behaviour flags). Open it and change at leastSECRET_KEYandPOSTGRES_PASSWORDbefore starting the containers.Start the Docker Compose stack
From the
dify/dockerfolder, run:docker compose up -dDocker pulls the images and starts the containers:
dify-api,dify-worker,dify-web,db(PostgreSQL),redis,weaviate,sandbox,ssrf_proxyandnginx. Verify everything isUpwithdocker compose ps. The operation typically takes 3 to 5 minutes depending on your bandwidth.Create the administrator account
Open
http://[YOUR-VPS-IP]in your browser. Dify automatically redirects to/installon first access.⚠️ Do this immediately: as long as the admin account does not exist, the
/installpage is open to anyone — whoever arrives first becomes the owner of your instance.Enter your e-mail address and a strong password. This account is the owner of the default workspace.
Point a domain name and enable HTTPS
For production use, associate a domain name with your VPS IP and deploy a TLS certificate. Dify's
docker-compose.yamlincludes an internal nginx listening on port 80. The most direct setup is to install Certbot on the host and create an external nginx vhost that proxies tolocalhost:80:sudo apt install nginx certbot python3-certbot-nginx -y sudo certbot --nginx -d your-domain.comThen update
CONSOLE_API_URL,CONSOLE_WEB_URL,SERVICE_API_URLandAPP_WEB_URLin.envwithhttps://your-domain.com, and restart withdocker compose up -d.
Post-Install Configuration: Models, API and Workspace
Once logged in, the first step is to register a model provider. In settings (icon top-right) → Model Providers, add your OpenAI, Anthropic, Mistral or any other supported API key. For a local model, enter your Ollama instance URL (http://[host-IP]:11434).
Dify also exposes its own REST API so you can integrate your applications into external pipelines. Find your API keys under Settings → API Keys. These keys allow you to query your Dify apps from n8n, Zapier or any Python script without going through the GUI.
The default workspace is the one created at first login. Invite members via Settings → Members and assign them Admin, Normal or Dataset operator roles.
Offline Plugins: Working Around the 500/404 Error on Self-Hosted Instances
Since November 2025 (GitHub issue #27720), many self-hosted users find that installing plugins from the Dify marketplace returns an HTTP 500 or 404 error on the /api/v1/plugins/download/ endpoint. The same plugins install fine on Dify Cloud, but self-hosted instances cannot reach the distribution backend.
Workaround 1 — Local .difypkg file. The most reliable method is to manually download the .difypkg file for the plugin from the Dify marketplace, then install it via the "Install from local file" option in the Dify interface. This method works regardless of connectivity to the download endpoint.
Workaround 2 — Disable signature verification. If you want to install unsigned plugins or develop your own, add the following variable to your .env file:
FORCE_VERIFYING_SIGNATURE=falseThen restart the plugin_daemon service:
docker compose restart plugin_daemon⚠️ Warning: disabling signature verification removes a security guard. Reserve this setting for development environments or plugins whose source you control. For production use with third-party users, prefer installation via a verified .difypkg file.
Connecting Ollama and n8n
Dify becomes particularly powerful combined with other self-hosted tools.
Ollama lets you run an LLM directly on your VPS or a server on the same network, without depending on an external API. After deploying Ollama, register it in Dify as a model provider with the URL http://[Ollama-IP]:11434. All generation then stays on your infrastructure — zero prompt leakage to the outside.
n8n is a workflow orchestrator that can drive Dify via its REST API. Create an HTTP Request node in n8n pointing to https://your-domain.com/v1/chat-messages with your Dify API key in the Authorization header. You can then trigger a Dify conversation from a web form, an inbound e-mail or a Slack webhook, and send the AI response to any destination.
Troubleshooting: The Most Common Errors
worker container restart loop. The Celery worker depends on Redis and PostgreSQL. Check their status with docker compose ps db redis and inspect the logs: docker compose logs worker --tail=50. If Redis is not yet ready at startup, a simple docker compose restart worker is enough.
plugin_daemon: PostgreSQL connection error. After a Dify update, plugin_daemon may fail with failed to connect to host=db. Verify that the db container is healthy (docker compose ps db). If the issue persists, wait 30 seconds after full startup before restarting: docker compose restart plugin_daemon.
Weaviate won't start (vm.max_map_count). Weaviate requires a high Linux kernel parameter. If the container exits immediately, apply: sudo sysctl -w vm.max_map_count=262144. To make it permanent, add vm.max_map_count=262144 to /etc/sysctl.conf.
Marketplace plugins: 500/404 error. See the "Offline Plugins" section above. If the issue is a network block between Docker containers and marketplace.dify.ai, verify that outbound port 443 is not blocked by your firewall: docker compose exec api curl -I https://marketplace.dify.ai.
WebSocket disconnected behind a reverse proxy. If AI response streaming breaks, your external nginx proxy is not forwarding WebSocket headers. Add to your location / block: proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade";.
Enable ServOrbit automatic backups to protect Dify's PostgreSQL volume (your apps, prompts and conversation histories). A daily disk snapshot covers all Docker volumes, including dify_db and dify_weaviate. If an update goes wrong, rollback takes just a few minutes from the client area.
The Official Documentation
For advanced configuration, the full list of environment variables and release notes, refer to the official Dify documentation. The docker-compose.yaml in the official repository remains the source of truth for image versions and inter-service dependencies.