Run n8n Locally for Free with Docker (Part 6 of 10): Environment Variables That Actually Matter
By Abhishek Patoliya · 2026-08-12
This is Part 6 of the series on running n8n locally with Docker for free. n8n works fine on its defaults, but a handful of environment variables are worth setting deliberately from the start — not because the setup breaks without them, but because fixing them later (especially the encryption key) is more disruptive than setting them correctly now.
← Back to the full series index
Adding Environment Variables in Compose
Extend the docker-compose.yml from Part 5 with an environment block:
services:
n8n:
image: n8nio/n8n
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_ENCRYPTION_KEY=your-generated-key-here
- GENERIC_TIMEZONE=America/New_York
- TZ=America/New_York
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
N8N_ENCRYPTION_KEY
This key encrypts every stored credential — API keys, OAuth tokens, database passwords — inside n8n's database. Left unset, n8n generates one automatically and stores it in the volume, which works fine as long as that volume is never lost. Setting it explicitly and saving a copy somewhere separate (a password manager, not a text file on the same disk) means you can recover your credentials even if you ever need to rebuild the volume from a backup. Generate one with:
openssl rand -hex 32
Set it once, and never change it on an instance with existing credentials — doing so makes those credentials permanently unreadable, since they were encrypted with the old key.
GENERIC_TIMEZONE and TZ
Any workflow using a Cron or Schedule trigger runs according to n8n's configured timezone. Left unset, this defaults to UTC — meaning a schedule you intended to fire at 9am your time might actually fire at 9am UTC instead, several hours off depending on where you are. Setting GENERIC_TIMEZONE (n8n's own setting) and TZ (the underlying container's system timezone) to your actual timezone avoids this entirely.
Variables You Don't Need Yet
N8N_HOST and WEBHOOK_URL matter once an external service needs to call a webhook into your local n8n — they tell n8n what public address to advertise for webhook URLs. For a purely local setup where you trigger workflows manually or on a schedule, leave these unset for now; Part 7 covers setting them correctly once a tunnel gives you an actual public address to point them at.
Applying the Changes
docker compose up -d
Compose detects the changed configuration and recreates just the container (not the volume, so your data is untouched) with the new environment variables applied.
Next Up
Continue to Part 7: Testing Webhooks Locally with a Free Tunnel, which gives your local instance the public address it needs to receive real webhook calls.
Written by Abhishek Patoliya, Senior n8n Developer & Automation Architect, Surat, India. Verified n8n Creator.