n8n · tool · fg-0339

$env in an n8n Code node or expression returns 'access to env vars denied' after 2.0

[ERROR: access to env vars denied]

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

Cause

n8n 2.0 flipped N8N_BLOCK_ENV_ACCESS_IN_NODE to true. With external task runners, Code node code runs in the runner container, so the setting and the variables must exist there too.

Fix

Prefer credentials or Variables over env access. If you need it, set N8N_BLOCK_ENV_ACCESS_IN_NODE=false on main and on the runner, and pass the variables to the runner container.

Apply

services:
  n8n:
    environment: [N8N_BLOCK_ENV_ACCESS_IN_NODE=false]
  n8n-runners:
    environment: [N8N_BLOCK_ENV_ACCESS_IN_NODE=false, MY_VAR=value]

Affects: n8n 2.0 and later; a UI false positive persisted until 2.29.0

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp