All Products
Search
Document Center

Data Management:Custom environment variables in Dify

Last Updated:Mar 28, 2026

Configure custom environment variables for your Dify instance in the Data Management Service (DMS) console to tune performance limits, service endpoints, authentication, and monitoring settings.

Usage notes

  • Service restart: Saving any changes to environment variables triggers an automatic restart of your Dify instance, causing a brief service interruption. Perform this operation during off-peak hours.

  • Whitelist restriction: Only variables listed in Supported environment variables can be modified.

  • Format requirement: All parameters must be provided as JSON key-value pairs ("Key": "Value"). All values must be strings.

Prerequisites

Before you begin, ensure that you have:

  • A Dify instance in the DMS console

  • The required permissions to manage the Dify instance

Set environment variables

  1. Log on to the DMS console. In the top navigation bar, choose Data + AI > Dify to open the Dify instance list.

    image

  2. In the Actions column for your Dify instance, click Resource Management.

    image.png

  3. In the Resource Management interface, click Environment Parameters.

    image.png

  4. In the Environment Parameters Configuration dialog box, modify or add environment variables:

    • Modify an existing variable: Edit the value directly in the input field. To restore a variable to its default, delete the entire key-value pair — the system applies the default after you save.

    • Add a new variable: Some whitelisted variables are not shown by default and must be added manually. The following example configures a custom domain. Add the key-value pairs below, replacing my_web.com with your domain.

      Note

      CONSOLE_API_URL, CONSOLE_WEB_URL, and APP_WEB_URL are modifiable only in Dify Account Edition and Enterprise Edition.

      {
        "HTTP_REQUEST_NODE_MAX_TEXT_SIZE": "1048576",
        ...
        "CONSOLE_API_URL": "http://my_web.com",
        "APP_API_URL": "http://my_web.com",
        "CONSOLE_WEB_URL": "http://my_web.com",
        "APP_WEB_URL": "http://my_web.com",
        "FILES_URL": "http://my_web.com"
      }

    image.png

  5. Click Save, then click Confirm in the confirmation dialog box.

  6. After saving, the system redeploys the instance. Check the result in the bottom-right corner:

    • Success: Three notifications appear in sequence: Environment parameters validated successfully, Environment parameters updated successfully, and Redeployment started. The Dify instance is restarting. image.png

    • Failure: An error such as Env key 'xxxx' is invalid indicates that the key xxxx is incorrect. Verify that the key is in the whitelist and spelled correctly.

Supported environment variables

URL endpoints

ParameterDefault valueDescriptionEdition
CONSOLE_API_URLDMS account login: https://dify-{region, for example cn-beijing}-dms.aliyuncs.com; Dify Account Edition or Enterprise Edition: http:// + assigned Application Load Balancer (ALB) public IPEndpoint for the console backend APIAccount & Enterprise only
APP_API_URLEndpoint for the application APIAll
CONSOLE_WEB_URLEndpoint for the console frontend webAccount & Enterprise only
APP_WEB_URLEndpoint for the application frontend webAccount & Enterprise only
FILES_URLEndpoint for the file serviceAll
SERVICE_API_URLEmptyEndpoint for the API serviceAll
TRIGGER_URLEmptyWebhook address for workflow triggersAll

Limits and timeouts

ParameterDefault valueDescriptionEdition
CODE_MAX_STRING_LENGTH800000Maximum length of output strings in code nodesAll
TEMPLATE_TRANSFORM_MAX_LENGTH800000Maximum length of strings in template transformationsAll
CODE_MAX_STRING_ARRAY_LENGTH1000Maximum number of elements in string arrays output by code nodesAll
CODE_MAX_OBJECT_ARRAY_LENGTH1000Maximum number of elements in object arrays output by code nodesAll
CODE_MAX_NUMBER_ARRAY_LENGTH1000Maximum number of elements in numeric arrays output by code nodesAll
CODE_MAX_DEPTH5Maximum nesting depth for objects or arrays output by code nodesAll
CODE_MAX_PRECISION20Maximum decimal places for numbers in code nodesAll
UPLOAD_FILE_SIZE_LIMIT50Maximum size (MB) for a single uploaded fileAll
UPLOAD_FILE_BATCH_LIMIT10Maximum number of files in a single batch uploadAll
HTTP_REQUEST_NODE_MAX_TEXT_SIZE1048576Maximum size (bytes) for text responses from HTTP request nodesAll
HTTP_REQUEST_NODE_MAX_BINARY_SIZE10485760Maximum size (bytes) for binary responses from HTTP request nodesAll
PLUGIN_MAX_PACKAGE_SIZE52428800Maximum size (bytes) for plugin installation packagesAll
GUNICORN_TIMEOUT360Maximum response wait time (seconds). Requests exceeding this timeout are terminated.All
APP_MAX_ACTIVE_REQUESTS0Maximum concurrent requests the application handles (0 means unlimited)All
APP_MAX_EXECUTION_TIME1200Maximum duration (seconds) for a single application executionAll
TOP_K_MAX_VALUE50Maximum Top-K value for knowledge base retrievalAll
TEXT_GENERATION_TIMEOUT_MS60000Timeout (milliseconds) for text generation requestsAll
LOOP_NODE_MAX_COUNT100Maximum number of iterations for loop nodesAll
MAX_TOOLS_NUM10Maximum number of tools an agent can useAll
MAX_PARALLEL_LIMIT10Maximum concurrency for parallel execution nodesAll
MAX_ITERATIONS_NUM99Maximum number of iterations for iteration nodesAll
MAX_TREE_DEPTH50Maximum node chain length from start to end in workflowsAll
FILES_ACCESS_TIMEOUT300Timeout (seconds) for file access operationsAll
ACCESS_TOKEN_EXPIRE_MINUTES60Expiration time (minutes) for access tokensAll

HTTP request timeouts

ParameterDefault valueDescriptionEdition
HTTP_REQUEST_MAX_CONNECT_TIMEOUT300Maximum connection timeout (seconds) for HTTP requestsAll
HTTP_REQUEST_MAX_READ_TIMEOUT600Maximum read timeout (seconds) for HTTP request responsesAll
HTTP_REQUEST_MAX_WRITE_TIMEOUT600Maximum write timeout (seconds) for HTTP requestsAll

Database and connection pool

ParameterDefault valueDescriptionEdition
SQLALCHEMY_POOL_SIZE60Maximum number of database connections in the connection poolAll
SQLALCHEMY_POOL_RECYCLE3600Connection recycle interval (seconds). Connections older than this value are rebuilt.All

Code execution

ParameterDefault valueDescriptionEdition
CODE_EXECUTION_CONNECT_TIMEOUT10Connection timeout (seconds) for code execution servicesAll
CODE_EXECUTION_READ_TIMEOUT60Read timeout (seconds) for code execution resultsAll
CODE_EXECUTION_WRITE_TIMEOUT10Write timeout (seconds) for code execution dataAll

Plugin and sandbox

ParameterDefault valueDescriptionEdition
DIFY_BACKWARDS_INVOCATION_WRITE_TIMEOUT60000Write timeout (milliseconds) for plugin reverse invocationsAll
DIFY_BACKWARDS_INVOCATION_READ_TIMEOUT60000Read timeout (milliseconds) for plugin reverse invocationsAll
PYTHON_ENV_INIT_TIMEOUT320Timeout (seconds) for initializing the plugin Python environmentAll

Authentication

ParameterDefault valueDescriptionEdition
ENABLE_EMAIL_PASSWORD_LOGINtrueAllow login with email and passwordAll
ENABLE_SOCIAL_OAUTH_LOGINfalseAllow login with social accounts via OAuthAll
ALLOW_REGISTERfalseAllow user self-registrationAll
ALLOW_CREATE_WORKSPACEfalseAllow users to create new workspacesAll
ALLOWED_OAUTH_DOMAINSEmptyDomains allowed for OAuth login (comma-separated)All
GOOGLE_CLIENT_IDEmptyClient ID for Google OAuthAll
GOOGLE_CLIENT_SECRETEmptyClient secret for Google OAuthAll
GITHUB_CLIENT_IDEmptyClient ID for GitHub OAuthAll
GITHUB_CLIENT_SECRETEmptyClient secret for GitHub OAuthAll

Monitoring

ParameterDefault valueDescriptionEdition
ARMS_ENABLEfalseEnable ARMS real-time application monitoringAll
ARMS_DIFY_API_APP_NAMEEmptyApplication name for the dify-api component in ARMSAll
ARMS_DIFY_PLUGIN_APP_NAMEEmptyApplication name for the dify-plugin-daemon component in ARMSAll
ARMS_DIFY_SANDBOX_APP_NAMEEmptyApplication name for the dify-sandbox component in ARMSAll
ARMS_REGION_IDEmptyRegion ID for ARMS monitoring (for example, cn-hangzhou)All
ARMS_LICENSE_KEYEmptyLicense Key required for ARMS monitoringAll