.env file.
Common Variables
These URL variables configure the addresses of Dify’s various services. For single-domain deployments behind Nginx (the default Docker Compose setup), these can be left empty—the system auto-detects from the incoming request. Configure them when using custom domains, split-domain deployments, or a reverse proxy.CONSOLE_API_URL
Default: (empty) The public URL of Dify’s backend API. Set this if you use OAuth login (GitHub, Google), Notion integration, or any plugin that requires OAuth—these features need an absolute callback URL to redirect users back after authorization. Also determines whether secure (HTTPS-only) cookies are used. Example:https://api.console.dify.ai
CONSOLE_WEB_URL
Default: (empty) The public URL of Dify’s console frontend. Used to build links in all system emails (invitations, password resets, notifications) and to redirect users back to the console after OAuth login. Also serves as the default CORS allowed origin ifCONSOLE_CORS_ALLOW_ORIGINS is not set.
If empty, email links will be broken—even in single-domain setups, set this if you use email features.
Example: https://console.dify.ai
SERVICE_API_URL
Default: (empty) The API Base URL shown to developers in the Dify console—the URL they copy into their code to call the Dify API. If empty, auto-detects from the current request (e.g.,http://localhost/v1). Set this to ensure a consistent URL when your server is accessible via multiple addresses.
Example: https://api.dify.ai
APP_API_URL
Default: (empty) The backend API URL for the WebApp frontend (published apps). This variable is only used by the web frontend container, not the Python backend. If empty, the Docker image defaults tohttp://127.0.0.1:5001.
Example: https://api.app.dify.ai
APP_WEB_URL
Default: (empty) The public URL where published WebApps are accessible. Required for the Human Input node in workflows—form links in email notifications are built as{APP_WEB_URL}/form/{token}. If empty, Human Input email delivery will not include valid form links.
Example: https://app.dify.ai
TRIGGER_URL
Default:http://localhost
The publicly accessible URL for webhook and plugin trigger endpoints. External systems use this address to invoke your workflows. Dify builds trigger callback URLs like {TRIGGER_URL}/triggers/webhook/{id} and displays them in the console.
For triggers to work from external systems, this must point to a public domain or IP address they can reach.
FILES_URL
Default: (empty; falls back toCONSOLE_API_URL)
The base URL for file preview and download links. Dify generates signed, time-limited URLs for all files (uploaded documents, tool outputs, workspace logos) and serves them to the frontend and multi-modal models.
Set this if you use file processing plugins, or if you want file URLs on a dedicated domain. If both FILES_URL and CONSOLE_API_URL are empty, file previews will not work.
Example: https://upload.example.com or http://<your-ip>:5001
INTERNAL_FILES_URL
Default: (empty; falls back toFILES_URL)
The file access URL used for communication between services inside the Docker network (e.g., plugin daemon, PDF/Word extractors). These internal services may not be able to reach the external FILES_URL if it routes through Nginx or a public domain.
If empty, internal services use FILES_URL. Set this when internal services can’t reach the external URL.
Example: http://api:5001
FILES_ACCESS_TIMEOUT
Default:300 (5 minutes)
How long signed file URLs remain valid, in seconds. After this time, the URL is rejected and the file must be re-requested. Increase for long-running processes; decrease for tighter security.
ENABLE_COLLABORATION_MODE
Default:false
Master switch for real-time collaboration on the Workflow canvas, covering simultaneous editing, in-canvas comments, and @mentions.
Setting this alone is not sufficient. Collaboration runs over WebSocket, which also requires:
SERVER_WORKER_CLASSset togeventwebsocket.gunicorn.workers.GeventWebSocketWorker(see Container Startup Configuration).NEXT_PUBLIC_SOCKET_URLset to a WebSocket URL your browser can reach (see CORS Configuration).
Upgrade and Connection headers on /socket.io/ (the bundled nginx template already does this). Running multiple API replicas requires sticky sessions.
System Encoding
Server Configuration
Logging
General
SECRET_KEY
Default: (pre-filled in.env.example; must be replaced for production)
Used for session cookie signing, JWT authentication tokens, file URL signatures (HMAC-SHA256), and encrypting third-party OAuth credentials (AES-256). Generate a strong key before first launch:
INIT_PASSWORD
Default: (empty) Optional security gate for first-time setup. When set, the/install page requires this password before the admin account can be created—preventing unauthorized setup if your server is exposed. Once setup is complete, this variable has no further effect. Maximum length: 30 characters.
Token & Request Limits
Container Startup Configuration
Only effective when starting with Docker image or Docker Compose.API Tool Configuration
Database Configuration
The database uses PostgreSQL by default. OceanBase, MySQL, and seekdb are also supported.Connection Pool
These control how Dify manages its pool of database connections. The defaults work well for most deployments.PostgreSQL Performance Tuning
These are passed as startup arguments to the PostgreSQL container—they configure the database server, not the Dify application.MySQL Performance Tuning
These are passed as startup arguments to the MySQL container—they configure the database server, not the Dify application.Redis Configuration
Configure these to connect Dify to your Redis instance. Dify supports three deployment modes: standalone (default), Sentinel, and Cluster.Redis SSL Configuration
Only applies whenREDIS_USE_SSL=true. These same settings are also used by the Celery broker when its URL uses the rediss:// scheme.
Redis Sentinel Mode
Sentinel provides automatic master discovery and failover for high availability. Mutually exclusive with Cluster mode.Redis Cluster Mode
Cluster mode provides automatic sharding across multiple Redis nodes. Mutually exclusive with Sentinel mode.Redis Connection Resilience
These tune client-side retry, timeout, and health-check behavior for Redis connections. Defaults are conservative; increase timeouts for cloud or WAN deployments where network latency is higher.Celery Configuration
Configure the background task queue used for dataset indexing, email sending, and scheduled jobs.CELERY_BROKER_URL
Default:redis://:difyai123456@redis:6379/1
Redis connection URL for the Celery message broker.
Direct connection format:
CORS Configuration
Controls cross-domain access policies for the frontend.File Storage Configuration
Configure where Dify stores uploaded files, dataset documents, and encryption keys. Each storage type has its own credential variables—configure only the one you’re using.STORAGE_TYPE
Default:opendal
Selects the file storage backend. Supported values: opendal, s3, azure-blob, aliyun-oss, google-storage, huawei-obs, volcengine-tos, tencent-cos, baidu-obs, oci-storage, supabase, clickzetta-volume, local (deprecated; internally uses OpenDAL with filesystem scheme).
OpenDAL (Default)
OpenDAL (Default)
OPENDAL_<SCHEME>_* and passes them to OpenDAL. For example, with OPENDAL_SCHEME=s3, set OPENDAL_S3_ACCESS_KEY_ID, OPENDAL_S3_SECRET_ACCESS_KEY, etc.fs scheme:S3
S3
Azure Blob
Azure Blob
Google Cloud Storage
Google Cloud Storage
Alibaba Cloud OSS
Alibaba Cloud OSS
Tencent Cloud COS
Tencent Cloud COS
OCI Object Storage
OCI Object Storage
Huawei OBS
Huawei OBS
Volcengine TOS
Volcengine TOS
Baidu OBS
Baidu OBS
Supabase
Supabase
ClickZetta Volume
ClickZetta Volume
CLICKZETTA_* connection parameters configured in the Vector Database section.Archive Storage
Separate S3-compatible storage for archiving workflow run logs. Used by the paid plan retention system to archive workflow runs older than the retention period to JSONL format. RequiresBILLING_ENABLED=true.
Vector Database Configuration
Configure the vector database used for knowledge base embedding storage and similarity search. Each provider has its own set of credential variables—configure only the one you’re using.VECTOR_STORE
Default:weaviate
Selects the vector database backend. If a dataset already has an index, the dataset’s stored type takes precedence over this setting. When switching providers in Docker Compose, COMPOSE_PROFILES automatically starts the matching container based on this value.
Supported values: weaviate, oceanbase, seekdb, qdrant, milvus, myscale, relyt, pgvector, pgvecto-rs, chroma, opensearch, oracle, tencent, elasticsearch, elasticsearch-ja, analyticdb, couchbase, vikingdb, opengauss, tablestore, vastbase, tidb, tidb_on_qdrant, baidu, lindorm, huawei_cloud, upstash, matrixone, clickzetta, alibabacloud_mysql, iris, hologres.
Weaviate
Weaviate
OceanBase / seekdb
OceanBase / seekdb
Qdrant
Qdrant
Milvus
Milvus
MyScale
MyScale
Couchbase
Couchbase
Hologres
Hologres
PGVector
PGVector
Vastbase
Vastbase
PGVecto.RS
PGVecto.RS
AnalyticDB
AnalyticDB
TiDB Vector
TiDB Vector
MatrixOne
MatrixOne
Chroma
Chroma
Oracle
Oracle
AlibabaCloud MySQL
AlibabaCloud MySQL
Relyt
Relyt
OpenSearch
OpenSearch
Tencent Cloud VectorDB
Tencent Cloud VectorDB
Elasticsearch
Elasticsearch
Baidu Vector DB
Baidu Vector DB
VikingDB
VikingDB
Lindorm
Lindorm
OpenGauss
OpenGauss
Huawei Cloud Search
Huawei Cloud Search
Upstash Vector
Upstash Vector
TableStore
TableStore
ClickZetta
ClickZetta
InterSystems IRIS
InterSystems IRIS
Knowledge Configuration
Annotation Import
Model Configuration
Multi-modal Configuration
NGINX_CLIENT_MAX_BODY_SIZE (default 100M). If you increase any upload limit above 100 MB, also increase NGINX_CLIENT_MAX_BODY_SIZE to match—otherwise Nginx rejects the upload with a 413 error.Sentry Configuration
Sentry provides error tracking and performance monitoring. Each service has its own DSN to separate error reporting.Notion Integration Configuration
Connect Dify to Notion as a knowledge base data source. Get integration credentials at https://www.notion.so/my-integrations.Mail Configuration
Dify sends emails for account invitations, password resets, login codes, and Human Input node notifications. Configure one of the three supported providers. Email links requireCONSOLE_WEB_URL to be set—see Common Variables.
Resend
Resend
SMTP
SMTP
SMTP_USE_TLS=true, SMTP_OPPORTUNISTIC_TLS=false, port 465), STARTTLS (SMTP_USE_TLS=true, SMTP_OPPORTUNISTIC_TLS=true, port 587), or plain (SMTP_USE_TLS=false, port 25).SendGrid
SendGrid
Others Configuration
Indexing
Token & Invitation
All token expiry variables control how long a one-time-use token stored in Redis remains valid. After expiry, the user must request a new token.Code Execution Sandbox
The sandbox is a separate service that runs Python, JavaScript, and Jinja2 code nodes in isolation.Workflow Runtime
Workflow Storage Repository
These select which backend implementation handles workflow execution data. The defaultSQLAlchemy repositories store everything in the database. Alternative implementations (e.g., Celery, Logstore) can be used for different storage strategies.
GraphEngine Worker Pool
Workflow Log Cleanup
HTTP Request Node
These configure the HTTP Request node used in workflows to call external APIs.Webhook
SSRF Protection
All outbound HTTP requests from Dify (HTTP nodes, image downloads, etc.) are routed through a proxy that blocks requests to internal/private IP ranges, preventing Server-Side Request Forgery (SSRF) attacks.Agent Configuration
Web Frontend Service
These variables are used by the Next.js web frontend container only, and do not affect the Python backend.Database Service
These configure the database containers directly in Docker Compose.Sandbox Service
The sandbox is an isolated service for executing code nodes (Python, JavaScript, Jinja2). Network access can be disabled for security.Nginx Reverse Proxy
CONSOLE_API_URL, CONSOLE_WEB_URL) to use https://.Certbot Configuration
SSRF Proxy
These configure the Squid-based SSRF proxy container that blocks requests to internal/private networks.Docker Compose
ModelProvider & Tool Position Configuration
Customize which tools and model providers are available in the app interface and their display order. Use comma-separated values with no spaces between items.Plugin Daemon Configuration
The plugin daemon is a separate service that manages plugin lifecycle (installation, execution, upgrades). The API communicates with it via HTTP.Creator Center Configuration
Creator Center (creators.dify.ai) is the submission portal where users upload Dify apps as templates. Submitted templates are reviewed and, once approved, listed on Dify Marketplace. The console’s Publish to Marketplace action exports the app’s DSL and uploads it to Creator Center on the user’s behalf. See Publish Apps to Marketplace for the user-facing flow.
OTLP / OpenTelemetry Configuration
OpenTelemetry provides distributed tracing and metrics collection. When enabled, Dify instruments Flask and exports telemetry data to an OTLP collector.Miscellaneous
Scheduled Tasks Configuration
Dify uses Celery Beat to run background maintenance tasks on configurable schedules.Record Retention & Cleanup
These control how old records are cleaned up. WhenBILLING_ENABLED is active, cleanup targets sandbox-tier tenants with a grace period. When billing is disabled (self-hosted), cleanup applies to all records within the retention window.
Aliyun SLS Logstore Configuration
Optional integration with Aliyun Simple Log Service for storing workflow execution logs externally instead of in the database. Enable by setting the repository configuration variables to use logstore implementations.Event Bus Configuration
Redis-based event transport between API and Celery workers.Vector Database Service Configuration
These configure the vector database containers themselves (not the Dify client connection). Only the variables for your chosenVECTOR_STORE are relevant.
Weaviate Service
Weaviate Service
Milvus Service (ETCD + MinIO)
Milvus Service (ETCD + MinIO)
OpenSearch Service
OpenSearch Service
PGVector / PGVecto.RS Service
PGVector / PGVecto.RS Service
Oracle / Chroma / Elasticsearch Services
Oracle / Chroma / Elasticsearch Services
IRIS / Other Services
IRIS / Other Services
Plugin Daemon Storage Configuration
The plugin daemon can store plugin packages in different storage backends. Configure only the provider matchingPLUGIN_STORAGE_TYPE.
Plugin S3 Storage
Plugin S3 Storage
Plugin Azure Blob Storage
Plugin Azure Blob Storage
Plugin Tencent COS Storage
Plugin Tencent COS Storage
Plugin Aliyun OSS Storage
Plugin Aliyun OSS Storage
Plugin Volcengine TOS Storage
Plugin Volcengine TOS Storage