Skip to content

任务运行器环境变量(Task runner environment variables)#

File-based configuration

You can add _FILE to individual variables to provide their configuration in a separate file. Refer to Keeping sensitive data in separate files for more details.

任务运行器 执行由 代码节点 定义的代码。

n8n 实例环境变量(n8n instance environment variables)#

Variable Type Default Description
N8N_RUNNERS_ENABLED Boolean false Are task runners enabled.
N8N_RUNNERS_MODE Enum string: internal, external internal How to launch and run the task runner. internal means n8n will launch a task runner as child process. external means an external orchestrator will launch the task runner.
N8N_RUNNERS_AUTH_TOKEN String Random string Shared secret used by a task runner to authenticate to n8n. Required when using external mode.
N8N_RUNNERS_BROKER_PORT Number 5679 Port the task broker listens on for task runner connections.
N8N_RUNNERS_BROKER_LISTEN_ADDRESS String 127.0.0.1 Address the task broker listens on.
N8N_RUNNERS_MAX_PAYLOAD Number 1 073 741 824 Maximum payload size in bytes for communication between a task broker and a task runner.
N8N_RUNNERS_MAX_OLD_SPACE_SIZE String The --max-old-space-size option to use for a task runner (in MB). By default, Node.js will set this based on available memory.
N8N_RUNNERS_MAX_CONCURRENCY Number 5 The number of concurrent tasks a task runner can execute at a time.
N8N_RUNNERS_TASK_TIMEOUT Number 300 The maximum time, in seconds, a task can run before the runner stops it and restarts. This value must be greater than 0.
N8N_RUNNERS_HEARTBEAT_INTERVAL Number 30 The interval, in seconds, at which the runner must send a heartbeat to the broker. If the runner doesn't send a heartbeat in time, the task stops and the runner restarts. This value must be greater than 0.
N8N_RUNNERS_INSECURE_MODE Boolean false Whether to disable all security measures in the task runner, for compatibility with modules that rely on insecure JS features. Discouraged for production use.
N8N_RUNNERS_TASK_REQUEST_TIMEOUT Number 20 How long (in seconds) a task request can wait for a runner to become available before timing out. This prevents workflows from hanging indefinitely when no runners are available. Must be greater than 0.

任务运行器启动器环境变量(Task runner launcher environment variables)#

变量 类型 默认值 描述
N8N_RUNNERS_LAUNCHER_LOG_LEVEL 枚举字符串: debug, info, warn, error info 要显示的日志消息类型。
N8N_RUNNERS_AUTH_TOKEN 字符串 - 用于认证 n8n 的共享密钥。
N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT 数字 15 在关闭空闲运行器前等待的秒数。
N8N_RUNNERS_TASK_BROKER_URI 字符串 http://127.0.0.1:5679 任务代理服务器(n8n 实例)的 URI。
N8N_RUNNERS_LAUNCHER_HEALTH_CHECK_PORT 数字 5680 启动器健康检查服务器的端口。
N8N_RUNNERS_MAX_PAYLOAD 数字 1 073 741 824 任务代理和任务运行器之间通信的最大负载大小(字节)。
N8N_RUNNERS_MAX_CONCURRENCY 数字 5 任务运行器一次可执行的并发任务数。

任务运行器环境变量(所有语言)(Task runner environment variables (all languages))#

变量 类型 默认值 描述
N8N_RUNNERS_GRANT_TOKEN 字符串 随机字符串 运行器用于与任务代理进行身份验证的令牌。此令牌由启动器自动提供。
N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT 数字 15 在关闭空闲运行器之前等待的秒数。
N8N_RUNNERS_TASK_BROKER_URI 字符串 http://127.0.0.1:5679 任务代理服务器(n8n 实例)的 URI。
N8N_RUNNERS_LAUNCHER_HEALTH_CHECK_PORT 数字 5680 启动器健康检查服务器的端口。
N8N_RUNNERS_MAX_PAYLOAD 数字 1 073 741 824 任务代理和任务运行器之间通信的最大负载大小(字节)。
N8N_RUNNERS_MAX_CONCURRENCY 数字 5 任务运行器一次可以执行的并发任务数量。

任务运行器环境变量(JavaScript)(Task runner environment variables (JavaScript))#

变量 类型 默认值 描述
NODE_FUNCTION_ALLOW_BUILTIN 字符串 - 允许用户在代码节点中导入特定的内置模块。使用 * 允许导入所有模块。n8n 默认禁用模块导入。
NODE_FUNCTION_ALLOW_EXTERNAL 字符串 - 允许用户在代码节点中导入特定的外部模块(来自 n8n/node_modules)。n8n 默认禁用模块导入。
N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION 布尔值 false 是否允许外部库的原型修改。设置为 true 以允许依赖运行时原型修改的模块(例如 puppeteer),但会降低安全性。
GENERIC_TIMEZONE * America/New_York 与 n8n 实例配置相同的默认时区
NODE_OPTIONS 字符串 - Node.js 的 选项
N8N_RUNNERS_MAX_OLD_SPACE_SIZE 字符串 用于任务运行器的 --max-old-space-size 选项(以 MB 为单位)。默认情况下,Node.js 会根据可用内存自动设置。

任务运行器环境变量(Python)(Task runner environment variables (Python))#

Variable Type Default Description
N8N_RUNNERS_STDLIB_ALLOW String - Python standard library modules that you can use in the Code node, including their submodules. Use * to allow all stdlib modules. n8n disables all Python standard library imports by default.
N8N_RUNNERS_EXTERNAL_ALLOW String - Third-party Python modules that are allowed to be used in the Code node, including their submodules. Use * to allow all external modules. n8n disables all third-party Python modules by default. Third-party Python modules must be included in the n8nio/runners image.
N8N_RUNNERS_BUILTINS_DENY String eval,exec,compile,open,input,breakpoint,getattr,object,type,vars,setattr,delattr,hasattr,dir,memoryview,__build_class__,globals,locals Python built-ins that you can't use in the Code node. Set to an empty string to allow all built-ins.
N8N_BLOCK_RUNNER_ENV_ACCESS Boolean true Whether to block access to the runner's environment from within Python code tasks. Set to false to enable all Python code node users access to the runner's environment via os.environ. For security reasons, environment variable access is blocked by default.