KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Reliability & Performance
n8n's `$env` variable (available when `N8N_BLOCK_ENV_ACCESS_IN_NODE` is not set to `true`) lets expressions read environment variables from the host system.
n8n's $env variable lets expressions read host environment variables, so you can define API endpoints, feature flags, and configuration as environment variables and switch between test and production by changing the environment rather than the workflow. The workflow definition stays identical across environments, and promotion from staging to production requires zero workflow changes.
n8n's $env variable (available when N8N_BLOCK_ENV_ACCESS_IN_NODE is not set to true) lets expressions read environment variables from the host system. This allows you to define API endpoints, feature flags, and configuration values as environment variables and switch between test and production by changing the environment, not the workflow.
Real-world example: Your workflow calls a payment processing API that has separate sandbox and production URLs. You want the same workflow to target sandbox in development and production in live.
services:
n8n:
environment:
PAYMENT_API_BASE_URL: "https://api.sandbox.paymentprovider.com/v1"
PAYMENT_API_MODE: "test"
NOTIFICATION_EMAIL: "dev-team@example.com"
services:
n8n:
environment:
PAYMENT_API_BASE_URL: "https://api.paymentprovider.com/v1"
PAYMENT_API_MODE: "live"
NOTIFICATION_EMAIL: "billing-alerts@example.com"
URL: {{ $env.PAYMENT_API_BASE_URL }}/charges
Method: POST
Condition:
{{ $env.PAYMENT_API_MODE }} equals "test"
True branch: Log the request (do not actually charge)
False branch: Process the real payment
This approach keeps your workflow definition identical across environments. Promotion from staging to production requires zero workflow changes.
Warning: Security Consideration
By default, $env exposes all host environment variables to expressions, including secrets like POSTGRES_PASSWORD. In production, set N8N_BLOCK_ENV_ACCESS_IN_NODE=true and use n8n credentials for sensitive values. Use $env only for non-secret configuration like URLs, feature flags, and mode switches.
Related: Always Set an Error Workflow on Every Production Workflow · Break Large Workflows into Sub-Workflows
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.