N8N data is not stored in Postgres

I just installed n8n using docker compose below

version: ‘3.8’
volumes:
db_storage:
n8n_storage:
redis_storage:
x-shared: &shared
restart: always
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
- EXECUTIONS_MODE=queue
- EXECUTIONS_PROCESS=main
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
links:
- postgres
- redis
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
services:
postgres:
image: postgres:11
container_name: n8n-postgres
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- POSTGRES_NON_ROOT_USER
- POSTGRES_NON_ROOT_PASSWORD
volumes:
- db_storage:/var/lib/postgresql/data
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
healthcheck:
test: [‘CMD-SHELL’, ‘pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}’]
interval: 5s
retries: 10
ports:
- 5432:5432
redis:
image: redis:6-alpine
container_name: n8n-redis
restart: always
volumes:
- redis_storage:/data
healthcheck:
test: [‘CMD’, ‘redis-cli’, ‘ping’]
interval: 5s
timeout: 5s
retries: 10
ports:
- 5433:6379
n8n:
<<: *shared
image: docker.n8n.io/n8nio/n8n
container_name: n8n
environment:
- GENERIC_TIMEZONE=Asia/Jakarta
- EXECUTIONS_TIMEOUT=3600
- EXECUTIONS_TIMEOUT_MAX=7200
- WEBHOOK_URL=https://webhook.local/
- N8N_METRICS=true
- EXECUTIONS_DATA_SAVE_ON_ERROR=all
- EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
- EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
- EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000
command: /bin/sh -c “n8n start --tunnel”
ports:
- 5431:5678
n8n-worker:
<<: *shared
image: docker.n8n.io/n8nio/n8n
container_name: n8n-worker
command: /bin/sh -c “sleep 5; n8n worker”
ports:
- 5434:5678
depends_on:
- n8n

and this setting for .env file

POSTGRES_USER=user
POSTGRES_PASSWORD=xxxxxxxx
POSTGRES_DB=user
POSTGRES_NON_ROOT_USER=user
POSTGRES_NON_ROOT_PASSWORD=xxxxx

Then I tried to access the postgres n8n database but couldn’t find any data like workflow_entity which was empty. even though we already have 6 workflows running.

Why this happened? Is there an error in the installation that I did? if yes, please provide information.

Does the data stay in SQLite because it defaults to that?

Thank You

  • n8n version: 0.236.0
  • **Database (default: SQLite): **
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 22

Hey @rusdiaman,

It sounds like the shared env options have not been passed through to the instance, Have you checked to see if they are set in the container? What I tend to do when setting up n8n is first set up one instance to point to the database then add the queue mode options once I have confirmed it is working in a basic state.

Hi @Jon ,
sorry for late reply.

how i can check “ther are set in the container” ?
Sorry i’m new in docker.

for now I’m trying the local suggestions you gave.
Thank you

Hey @rusdiaman,

You could run something like docker exec n8n /bin/sh -c /usr/bin/env and see what that outputs, If you are new to Docker though I would definitely start off with an easier set up so you can get your head around how everything sits together then make it more complex.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.