Environment Variables
How to Set Environment Variables?
Git Source Code or create-nocobase-app Installation Method
Set environment variables in the .env file in the project's root directory. After modifying the environment variables, kill the application process and restart it.
Docker Installation Method
Modify the docker-compose.yml configuration and set the environment variables in the environment parameter. Example:
You can also use env_file to set environment variables in the .env file. Example:
After modifying the environment variables, rebuild the app container:
Global Environment Variables
TZ
Used to set the application's time zone, with the default being the system's time zone.
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Time-related operations will be handled according to this time zone. Changing TZ may affect date values in the database. For more details, refer to Date & Time Overview.
APP_ENV
Application environment, default is development, options include:
productionproduction environmentdevelopmentdevelopment environment
APP_KEY
The application's secret key, used for generating user tokens, etc. Change it to your own application key and ensure it is not leaked.
If APP_KEY is changed, old tokens will become invalid.
APP_PORT
Application port, default is 13000.
API_BASE_PATH
NocoBase API address prefix, default is /api/.
API_BASE_URL
CLUSTER_MODE
v1.6.0+
The multi-core (cluster) mode for starting app. If this variable is configured, it will be passed to the pm2 start command as the -i <instances> parameter. The options are consistent with the pm2 -i parameter (refer to PM2: Cluster Mode), including:
max: Use the maximum number of CPU cores-1: Use the maximum number of CPU cores minus one<number>: Specify the number of cores
The default value is empty, meaning it is not enabled.
This mode requires the use of plugins related to cluster mode. Otherwise, the functionality of the application may encounter unexpected issues.
For more information, see Cluster Mode.
PLUGIN_PACKAGE_PREFIX
Plugin package prefix, default is @nocobase/plugin-,@nocobase/preset-.
For example, to add the hello plugin to the my-nocobase-app project, the plugin's full package name would be @my-nocobase-app/plugin-hello.
PLUGIN_PACKAGE_PREFIX can be configured as:
The correspondence between plugin name and package name is as follows:
usersplugin package name is@nocobase/plugin-usersnocobaseplugin package name is@nocobase/preset-nocobasehelloplugin package name is@my-nocobase-app/plugin-hello
DB_DIALECT
Database type, options include:
mariadbmysqlpostgres
DB_HOST
Database host (required when using MySQL or PostgreSQL databases).
Default is localhost.
DB_PORT
Database port (required when using MySQL or PostgreSQL databases).
- Default port for MySQL and MariaDB is 3306
- Default port for PostgreSQL is 5432
DB_DATABASE
Database name (required when using MySQL or PostgreSQL databases).
DB_USER
Database user (required when using MySQL or PostgreSQL databases).
DB_PASSWORD
Database password (required when using MySQL or PostgreSQL databases).
DB_TABLE_PREFIX
Data table prefix.
DB_UNDERSCORED
Whether database table and field names are converted to snake case style. Default is false. If using a MySQL (MariaDB) database with lower_case_table_names=1, then DB_UNDERSCORED must be set to true.
When DB_UNDERSCORED=true, the actual table and field names in the database will not match what is displayed in the UI. For example, orderDetails will be stored as order_details in the database.
DB_LOGGING
Database log switch, default is off, options include:
ononoffoff
DB_POOL_MAX
Maximum number of connections in the pool. Default is 5.
DB_POOL_MIN
Minimum number of connections in the pool. Default is 0.
DB_POOL_IDLE
The maximum time, in milliseconds, that a connection can be idle before being released. Default is 10000 (10 seconds).
DB_POOL_ACQUIRE
The maximum time, in milliseconds, that the pool will try to get a connection before throwing an error. Default is 60000 (60 seconds).
DB_POOL_EVICT
The time interval, in milliseconds, after which the connection pool will remove idle connections. Default is 1000 (1 second).
DB_POOL_MAX_USES
The number of times a connection can be used before it is discarded and replaced. Default is 0 (unlimited).
LOGGER_TRANSPORT
Log output method, multiple values separated by ,. Default is console in development, console,dailyRotateFile in production.
Options:
console-console.logfile- Output to a filedailyRotateFile- Output to daily rotating files
LOGGER_BASE_PATH
File-based log storage path, default is storage/logs.
LOGGER_LEVEL
Output log level. Default is debug in development and info in production. Options:
errorwarninfodebugtrace
The database log output level is debug, controlled by DB_LOGGING, and is unaffected by LOGGER_LEVEL.
LOGGER_MAX_FILES
Maximum number of log files to keep.
- When
LOGGER_TRANSPORTisfile: Default is10. - When
LOGGER_TRANSPORTisdailyRotateFile: Use[n]dto represent days. Default is14d.
LOGGER_MAX_SIZE
Log rotation by size.
- When
LOGGER_TRANSPORTisfile: Unit isbyte. Default is20971520 (20 * 1024 * 1024). - When
LOGGER_TRANSPORTisdailyRotateFile: Use[n]k,[n]m,[n]g. Default is not set.
LOGGER_FORMAT
Log print format. Default is console in development and json in production. Options:
consolejsonlogfmtdelimiter
Reference: Log Format
CACHE_DEFAULT_STORE
Unique identifier for the caching method, specifying the server's default cache. Default is memory. Built-in options include:
memoryredis
CACHE_MEMORY_MAX
Maximum number of items in the memory cache. Default is 2000.
CACHE_REDIS_URL
Redis connection URL, optional. Example: redis://localhost:6379
TELEMETRY_ENABLED
Enable telemetry data collection. Default is off.
TELEMETRY_METRIC_READER
Enabled monitoring metric collectors. Default is console. Other values should refer to the names registered by corresponding collector plugins, such as prometheus. Multiple values are separated by ,.
TELEMETRY_TRACE_PROCESSOR
Enabled trace data processors. Default is console. Other values should refer to the names registered by corresponding processor plugins. Multiple values are separated by ,.
SERVER_REQUEST_WHITELIST
Whitelist of allowed targets for server-initiated outbound HTTP requests, used to prevent SSRF (Server-Side Request Forgery) attacks. Accepts a comma-separated list of exact IPs, CIDR ranges, exact hostnames, and single-level wildcard subdomains.
Applies to: Workflow "HTTP Request" nodes and Custom Request action buttons. Relative-path requests (calls to the NocoBase API itself) are not affected.
When not set: All http/https outbound requests are allowed (existing behaviour). When set: Only requests whose host matches a whitelist entry are permitted; non-matching requests will raise an error.
Supported formats:
Experimental Environment Variables
APPEND_PRESET_LOCAL_PLUGINS
Used to append preset local plugins. The value is the package name (the name parameter in package.json), with multiple plugins separated by commas.
:::info
- Ensure the plugin is downloaded locally and can be found in the
node_modulesdirectory. For more details, see Plugin Organization. - After adding the environment variable, the plugin will appear on the plugin manager page only after an initial installation (
nocobase install) or upgrade (nocobase upgrade). :::
APPEND_PRESET_BUILT_IN_PLUGINS
Used to append built-in plugins that are installed by default. The value is the package name (the name parameter in package.json), with multiple plugins separated by commas.
:::info
- Ensure the plugin is downloaded locally and can be found in the
node_modulesdirectory. For more details, see Plugin Organization. - After adding the environment variable, the plugin will be automatically installed or upgraded during the initial installation (
nocobase install) or upgrade (nocobase upgrade). :::
Temporary Environment Variables
The installation of NocoBase can be assisted by setting temporary environment variables, such as:
INIT_APP_LANG
Language at the time of installation. Default is en-US. Options include:
en-USzh-CN
INIT_ROOT_EMAIL
Root user email.
INIT_ROOT_PASSWORD
Root user password.
INIT_ROOT_NICKNAME
Root user nickname.
Other Plugin-Provided Environment Variables
WORKFLOW_SCRIPT_MODULES
Workflow JavaScript node available modules list. For details, see "JavaScript Node: Using External Modules".
WORKFLOW_LOOP_LIMIT
Maximum loop count limit for workflow loop nodes. For details, see "Loop Node".

