Environment variables not accessible in self-hosted setup - $env returns empty object

Hello everyone!

Problem

I’m experiencing an issue with accessing environment variables in my self-hosted n8n setup. Expressions like {{$env["TEST"]}}, return null, and $env itself returns an empty object {}.
This used to work before (as referenced in this previous discussion: How to define custom environment variables available in the n8n workflow - #14 by sscarduzio ), but now it seems like environment variables are no longer accessible from workflows.

Information on your n8n setup

  • n8n version: 1.107.3
  • Running n8n via Docker
  • Environment variables are set on the system level

Has anyone encountered this issue recently? Any insights on what might have changed or how to troubleshoot this would be greatly appreciated.

Thanks in advance for any help!

Hey @sasha hope all is good. Welcome to the community.

$env most certainly does work for me. See both syntaxes:


if you would like to expand on what you are trying to captures and how you are setting you variable, please add more details.

UPD:
Also check if N8N_BLOCK_ENV_ACCESS_IN_NODE is either not set or set to false.
see this doc for more info about it.

Pretty sure this can be disabled. Or it might be by default now.
So make sure to check your ENV variables to see if that isn’t the case. :slight_smile:

Good point, I’ve updated the answer to indicate the variable and the doc about it.

Thank you for your help! I’ve set N8N_BLOCK_ENV_ACCESS_IN_NODE to false, but unfortunately that hasn’t resolved the issue yet. I’ll continue experimenting and will post back with the results.

Loop us in, we can try to help along the way. How do you set your env?

I’m also experiencing the same - I’m using Render to host the instance (free plan), and adding the N8N_BLOCK_ENV_ACCESS_IN_NODE env var doesn’t seem to work for me.
Not sure if it’s a Render-specific thing, but when I go to generate the render.yaml file, it shows:

# Exported from Render on 2025-11-05T09:12:25Z
version: "1"
projects:
- name: My project
  environments:
  - name: Production
    services:
    - type: web
      name: n8n
      runtime: image
      image:
        url: docker.n8n.io/n8nio/n8n:latest
      plan: free
      envVars:
      - key: GOOGLE_CLIENT_SECRET
        sync: false
      - key: N8N_BLOCK_ENV_ACCESS_IN_NODE
        sync: false
      - key: GOOGLE_CLIENT_ID
        sync: false
      - key: WEBHOOK_URL
        sync: false
      - key: N8N_PROTOCOL
        sync: false
      - key: N8N_HOST
        sync: false
      region: oregon
      autoDeployTrigger: commit

{{ process.env }} also return all Env. vars:

related post:

Interesting.. so even if it does show undefined, the value is still there?
I tried using process.env as well, but it still seems like it’s not being exposed.
As an example, when I’m setting up my Google Sheets credentials, the payload comes up empty for the secret from the OAuth callback:

Ok, it turns out it is a Render specific thing - the Secrets section in Render are used only during build time, and if it’s needed during runtime I’d need to have my own Docker build image vs pulling directly from the official n8n docker image.