Black Friday: Save 10% for life on all of our VPS plans, now through Cyber Monday

10% off on selected plans for as long as you keep the service · new orders · up to 10 uses per customer · ends Dec 1, 2026, 12:00 AM EST.

See plans
Guideschevron_rightServers

Servers · 8 min read · Updated

How to Self-Host Dify on a VPS

To self-host Dify, clone a release of its repository on a server with at least 2 cores and 4 GiB of memory, copy docker/.env.example to docker/.env, set the required sandbox token and replace the bundled development passwords, then run docker compose up -d. Open /install straight away to create the administrator, turn on HTTPS, and upgrade by checking out a newer release tag.

1. Prepare the Server

On Ubuntu 24.04, secure the server and install Docker (Dify asks for Compose 2.35.0 or later; docker compose version shows yours), plus Git and OpenSSL. Point a domain at the server for HTTPS later.

Until the administrator account exists, whoever opens the setup page first can create it. If you turned on the firewall on your server's page in the dashboard, allow ports 80 and 443 only from your own address for now. That firewall sits outside the server, so Docker cannot open a way round it.

2. Download a Release and Configure It

Pick the newest tag on Dify's GitHub releases page and use it in place of 1.x.y:

git clone --branch 1.x.y --depth 1 https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
openssl rand -hex 32      # run once for each secret below

In .env, set DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN to a random value; the agent backend does not start without it. Then replace the development credentials Dify ships with, each with its own random value: DB_PASSWORD, REDIS_PASSWORD, SANDBOX_API_KEY, CODE_EXECUTION_API_KEY, WEAVIATE_API_KEY, PLUGIN_DAEMON_KEY, PLUGIN_DIFY_INNER_API_KEY and DIFY_AGENT_API_TOKEN. Do it before the first start, as the databases keep the passwords they were created with.

3. Start It and Create the Administrator

docker compose up -d
docker compose ps --all       # init_permissions should show Exited (0); the rest Up

Open http://203.0.113.10/install (your server's address), create the administrator account, then sign in at http://203.0.113.10. Only Dify's Nginx publishes ports, 80 by default; the database, Redis, sandbox and vector store stay inside Docker.

4. Turn On HTTPS

Dify's bundled Nginx can serve HTTPS: NGINX_HTTPS_ENABLED and the certificate and certbot settings in .env control it, and Dify's HTTPS documentation for your version gives the steps. Set the public URLs in its URL settings to https:// addresses too: the docs note that secure cookies need both the console API and web URLs to start with https://. Once it works, open ports 80 and 443 to everyone who should use it.

After changing .env, apply it with docker compose up -d, not docker compose restart.

5. Connect Models

Under Integrations → Model Provider, add a provider's API key, or a provider for a model you host. Keeping the model on your own hardware keeps prompts and documents off third-party services: a GPU server running vLLM or Ollama can serve several Dify apps at once.

Upgrades and Backups

Back up .env and the docker/volumes/ folder first, read the release's upgrade notes, then:

cd dify/docker
docker compose stop
git fetch --tags origin
git checkout 1.x.z            # the new release tag
docker compose config --quiet
docker compose pull
docker compose up -d
docker compose ps --all

Never copy .env.example over your .env during an upgrade; it would wipe your settings. Nightly, copy docker/volumes/ and .env off the server with Borg to a storage box. For simpler automations without the AI app builder, n8n may be enough; for search over your own vectors, see Qdrant.

Common Questions

  • What is Dify?

    An open-source platform for building applications on language models: chatbots, agents, workflows and RAG pipelines over your own documents, assembled in a browser and published as web apps or APIs. It connects to hosted model providers and to models you run yourself.

  • What server does Dify need?

    Dify's documentation gives at least 2 CPU cores and 4 GiB of memory, with Docker Compose 2.35.0 or later. That runs Dify itself; documents, vector storage and many users want more, and running the language model on the same machine needs far more again.

  • Can I use Dify commercially?

    Yes, its licence allows commercial use, including as the backend for your own products. It is a modified Apache 2.0 licence, though: you may not operate it as a multi-tenant service for other organisations without Dify's written permission, or remove its logo and copyright notices from the console and apps.

  • Does it work with local models?

    Yes. Model providers are added under Integrations → Model Provider, and the list includes providers for self-hosted models as well as the hosted APIs. For a model on your own GPU server, see serving an LLM API with vLLM.

Plans and prices

VPS Plans

KVM servers with NVMe storage and full root access for your AI apps.

See all plans
  • Bronze

    3 vCPU · 6 GB RAM · 75 GB NVMe

    2 TB transfer

    $37.50/mo

    Configure inAshburnDallas
  • Silver

    4 vCPU · 8 GB RAM · 100 GB NVMe

    4 TB transfer

    $46.50/mo

    Configure inAshburnDallas
  • Gold

    6 vCPU · 12 GB RAM · 150 GB NVMe

    6 TB transfer

    $60.00/mo

    Configure inAshburnDallas
  • Diamond

    8 vCPU · 16 GB RAM · 200 GB NVMe

    8 TB transfer

    $73.50/mo

    Configure inAshburnDallas

Network port: 10 Gbps in Ashburn, VA, 50 Gbps in Dallas, TX. Pick the location when you configure.

Keep Reading

All guides