Configure custom environment variables for Dify
This topic describes how to set or update custom environment variables for your Dify instance in the Alibaba Cloud DMS console to optimize performance, access policies, service URLs, and other configurations.
Notes
Service restart: Saving a change to an environment variable automatically restarts the Dify instance, causing a brief service interruption. Perform this operation during off-peak hours.
Whitelist restriction: For security, you can only modify environment variables on the whitelist. For the complete list, see Supported environment variables.
Formatting requirements: All parameters must be provided in the standard JSON key-value pair (
"Key": "Value") format, and eachValuemust be a string.
Procedure
Log in to the DMS console. In the top navigation bar, click to open the Dify instance list page.
In the Actions column for the target Dify instance, click Resource Management.
On the resource management page, click Environment Parameters.
In the Environment Parameter Configuration dialog box, modify or add environment variables.
Modify an existing parameter:
Edit the value directly in the input box.
To restore the default value, delete the key-value pair. The system automatically restores the default value when you save.
Add a new parameter:
Some whitelisted parameters are not displayed by default and must be added manually.
For example, to configure a custom domain name: In the editor, manually add the following key-value pair. You can replace
my_web.comwith your actual domain name.NoteCONSOLE_API_URL,CONSOLE_WEB_URL, andAPP_WEB_URLcan only be modified in the Dify Account Edition or 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" }
After making your changes, click Save, and then click OK in the confirmation dialog box.
After you save the settings, the system redeploys the instance.
Success status:
If you see the messages Environment parameter validation successful, Environment parameter update successful, and Redeployment has started in the lower-right corner, the update was successful and the Dify instance is restarting.
Failure status:
If the
Env key 'xxxx' is invaliderror occurs, it means that the corresponding keyxxxxis invalid. Carefully check whether the key is in the whitelist and is spelled correctly.For example, the environment variable key
UPLOAD_FILE__LIMIT(which is misspelled with a double underscore) will trigger this error message.
Supported environment variables
Parameter | Default | Description |
| 800000 | The maximum length of a string output from a code node. |
| 800000 | The maximum length of a string in a template transformation. |
| 1000 | The maximum number of elements in a string array output from a code node. |
| 1000 | The maximum number of elements in an object array output from a code node. |
| 1000 | The maximum number of elements in a number array output from a code node. |
| 5 | The maximum nesting depth for objects or arrays output from a code node. |
| 20 | The maximum precision (number of decimal places) for numbers in a code node. |
| 60 | The size of the database connection pool (maximum number of connections). |
| 3600 | The connection recycle timeout in seconds. Connections older than this time are recycled. |
| 52428800 | The maximum allowed size for a plugin package in bytes. |
| 360 | The maximum time in seconds to wait for a response. A request is terminated if it exceeds this timeout. |
| 50 | The maximum size of a single uploaded file in MB. |
| 10 | The maximum number of files in a single batch upload. |
| 1048576 | The maximum size of a text response from an HTTP request node in bytes. |
| 10485760 | The maximum size of a binary response from an HTTP request node in bytes. |
|
| The access URL for the console backend API. Modifiable only in Dify Account Edition or Dify Enterprise Edition. |
| The access URL for the application API. | |
| The access URL for the console frontend. Modifiable only in Dify Account Edition or Dify Enterprise Edition. | |
| The access URL for the application frontend. Modifiable only in Dify Account Edition or Dify Enterprise Edition. | |
| The access URL for the file service. | |
| 60000 | The timeout, in milliseconds, for plugin backward invocation write operations. |
| 60000 | The timeout, in milliseconds, for plugin backward invocation read operations. |
| 320 | The timeout in seconds for plugin Python environment initialization. |
| 50 | The maximum allowed value for Top-K in knowledge base retrieval. |
| 60000 | The timeout in milliseconds for text generation requests. |
| 100 | The maximum number of iterations for a loop node. |
| 10 | The maximum number of tools an agent can use. |
| 10 | The maximum number of concurrent executions for a parallel execution node. |
| 99 | The maximum number of iterations for an iteration node. |
| 50 | The longest path of nodes from start to end in a workflow. |
| Empty | The access URL for the API service. |
| Empty | The callback URL for the workflow trigger. |
| 300 | The timeout in seconds for file access operations. |
| 300 | The maximum timeout in seconds for establishing an HTTP connection. |
| 600 | The maximum timeout in seconds for reading an HTTP response. |
| 600 | The maximum timeout in seconds for writing HTTP request data. |
| 10 | The timeout in seconds for connecting to the code execution service. |
| 60 | The timeout in seconds for reading code execution results. |
| 10 | The timeout in seconds for writing code execution data. |
| 60 | The expiration time, in minutes, for an access token. |
| 0 | The maximum number of concurrent requests the application can handle (0 means unlimited). |
| 1200 | The maximum execution time for a single application run in seconds. |
| false | Specifies whether to enable social account OAuth login. |
| false | Specifies whether to allow user registration. |
| false | Specifies whether to allow the creation of new workspaces. |
| Empty | The client ID for the Google OAuth application. |
| Empty | The client secret for the Google OAuth application. |
| Empty | The client ID for the GitHub OAuth application. |
| Empty | The client secret for the GitHub OAuth application. |
| true | Specifies whether to allow login with an email and password. |
| Empty | A comma-separated list of domains allowed to log in via OAuth. |
| false | Specifies whether to enable Application Real-Time Monitoring (ARMS). |
| Empty |
|
| Empty |
|
| Empty |
|
| Empty | The region ID for ARMS monitoring (such as |
| Empty | The license key required for ARMS integration. |