This document outlines the setup for a local n8n instance using Docker Compose, with persistent PostgreSQL storage and configured for access via Tailscale.
- Docker Desktop for Windows: Ensure it is installed and running.
- Tailscale: Ensure it is installed and running on this development machine.
All files and data will be relative to the directory containing this README.md and docker-compose.yml (expected to be d:/app_live_n8n).
./docker-compose.yml: The Docker Compose configuration file../n8n_data/: This directory will be created automatically on your host to store persistent n8n data (workflows, credentials, etc.).postgres_data_vol: This is a Docker named volume (managed by Docker, not directly in this directory) that stores persistent PostgreSQL database files. The actual name Docker uses will be prefixed, e.g.,app_live_n8n_postgres_data_vol.
The following docker-compose.yml file defines the n8n and PostgreSQL services:
services:
postgres:
image: postgres:15
restart: always
environment:
- POSTGRES_USER=n8nuser
- POSTGRES_PASSWORD=n8nDefaultDevPassword123! # Documented as is, recommend changing
- POSTGRES_DB=n8ndb
volumes:
- postgres_data_vol:/var/lib/postgresql/data
networks:
- n8n-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8nuser -d n8ndb"]
interval: 10s
timeout: 5s
retries: 5
n8n:
image: n8nio/n8n
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8ndb
- DB_POSTGRESDB_USER=n8nuser
- DB_POSTGRESDB_PASSWORD=n8nDefaultDevPassword123!
- GENERIC_TIMEZONE=America/Chicago # USER ACTION REQUIRED: Verify or change
- WEBHOOK_URL=http://100.113.4.39:5678 # USER ACTION REQUIRED: Verify or change
# - N8N_DIAGNOSTICS_ENABLED=false # Uncomment to disable telemetry
volumes:
- ./n8n_data:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
networks:
- n8n-network
networks:
n8n-network:
driver: bridge
volumes:
postgres_data_vol:These are the environment variables used in the docker-compose.yml.
PostgreSQL Service (postgres):
POSTGRES_USER:n8nuserPOSTGRES_PASSWORD:n8nDefaultDevPassword123!- Note: For development. It's good practice to change this to a unique, strong password.
POSTGRES_DB:n8ndb
n8n Service (n8n):
DB_TYPE:postgresdbDB_POSTGRESDB_HOST:postgresDB_POSTGRESDB_PORT:5432DB_POSTGRESDB_DATABASE:n8ndbDB_POSTGRESDB_USER:n8nuserDB_POSTGRESDB_PASSWORD:n8nDefaultDevPassword123!GENERIC_TIMEZONE:America/Chicago- USER ACTION REQUIRED: Verify this is your correct timezone. If not, change it. Find valid timezones here.
WEBHOOK_URL:http://100.113.4.39:5678- USER ACTION REQUIRED: Verify this is your machine's correct Tailscale IP address or MagicDNS hostname and port. This is critical for webhook functionality.
N8N_DIAGNOSTICS_ENABLED: (Optional, commented out) Set tofalseto disable n8n telemetry.
- Ensure Docker Desktop is running.
- Verify
docker-compose.ymlcontent (from section 3.1) is saved in your project directory (d:/app_live_n8n). - Verify Placeholders in
docker-compose.yml:- Ensure
GENERIC_TIMEZONEis correct for your location. - Ensure
WEBHOOK_URLis correct with your Tailscale IP/hostname. - (Recommended) Change
POSTGRES_PASSWORDif desired.
- Ensure
- Open a terminal (Command Prompt, PowerShell, or Windows Terminal) and navigate to your project directory (
d:/app_live_n8n). - Start the services:
The
docker-compose up -d
-dflag runs the containers in detached mode. If they are already running, this command will recreate them if changes were made to thedocker-compose.ymlor images. - Access n8n:
- Locally on the host machine:
http://localhost:5678 - Via Tailscale (from any device on your Tailscale network):
http://100.113.4.39:5678(or your verified Tailscale URL)
- Locally on the host machine:
To view logs for a specific service:
docker-compose logs -f n8n
docker-compose logs -f postgresPress Ctrl+C to stop following logs.
To stop and remove the containers (data in named volumes like postgres_data_vol and host-bound volumes like ./n8n_data will persist):
docker-compose downTo also remove named volumes (like postgres_data_vol), use docker-compose down -v. This will delete the PostgreSQL database.
If previously stopped:
docker-compose up -d- Pull the latest images specified in your
docker-compose.yml:docker-compose pull
- Recreate the containers with the new images:
It's always a good idea to back up your data before significant updates.
docker-compose up -d --remove-orphans
Persistent data for n8n is stored in ./n8n_data on your host. PostgreSQL data is stored in a Docker named volume (e.g., app_live_n8n_postgres_data_vol).
- n8n Data (
./n8n_data): This folder on your host contains your workflows, credentials, etc. Regularly back up this entire folder. - PostgreSQL Data (Named Volume):
- To use
pg_dump(recommended for live backups):This command creates adocker-compose exec -T postgres pg_dump -U n8nuser -d n8ndb > n8n_database_backup.sql
n8n_database_backup.sqlfile on your host in the current directory. - To restore, you would typically use
psql. - For backing up the raw named volume data, refer to Docker documentation (e.g., running a temporary container to tar the volume contents).
- To use
- Port Conflicts: If port
5678is already in use on your host, n8n will fail to start. Change the host port indocker-compose.yml(e.g.,"127.0.0.1:5679:5678") and update yourWEBHOOK_URLaccordingly. - "service "postgres" is unhealthy" or n8n connection issues:
- Check
docker-compose logs -f postgres. - Ensure
POSTGRES_USER,POSTGRES_PASSWORD, andPOSTGRES_DBin thepostgresservice environment match theDB_POSTGRESDB_*variables in then8nservice.
- Check