AutomatedReality, home

n8n Setup: Run n8n Locally with Docker and Postgres

Overview & Architecture

This blueprint runs n8n on your own computer or home server with Docker Compose. Instead of n8n’s default SQLite file, n8n stores its workflows, credentials and executions in PostgreSQL. There is no n8n workflow to import here: the build is the docker-compose.yml and .env files themselves.

Two services run from one compose file:

Both services read their settings from the same .env file.

The Pipeline

  1. Write docker-compose.yml: the two services, their volumes and health checks.
  2. Write .env: database name, user and password, the n8n encryption key, and n8n’s DB_TYPE=postgresdb / DB_POSTGRESDB_* settings.
  3. Validate: docker compose config --quiet && echo ok.
  4. Start: docker compose up -d creates the network, both volumes and both containers.
  5. Check health: docker compose ps showed both containers (healthy) after about a minute.
  6. Prove it: docker compose exec n8n wget -qO- http://localhost:5678/healthz answers, and a psql query in the postgres container returned n8n|36: 36 tables n8n created in its PostgreSQL database.
  7. Open n8n at http://localhost:5678 and create the owner account.

What You Need

The .env file used in the video (placeholder values; replace every change-me before the first start and never commit this file):

POSTGRES_DB=n8n
POSTGRES_USER=n8n
POSTGRES_PASSWORD=change-me
N8N_ENCRYPTION_KEY=change-me-random-key
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=postgres
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n
DB_POSTGRESDB_PASSWORD=change-me

Key Deployment Hurdles & Solutions

Download the docker-compose.yml

The exact compose file from the video. Save it in an empty folder as docker-compose.yml, create the .env file above next to it, then run docker compose up -d.

Download docker-compose.yml

Download the Companion System Prompt (.md)

Enter your first name to personalize the setup assistant prompt so your AI helper can walk you through Docker Compose, PostgreSQL and n8n step by step and help with any errors. Add your email optionally to get notified when new home lab blueprints drop.