All n8n data is lost after docker stop & restart

Describe the problem/error/question

Hello! Totally newbie in n8n, but I would like to use it in some my projects later.
Each time I manually stop and restart n8n via docker, I am loosing all my config. This is n8n Community Edition.
I need to register my account every time and all my workflows and credentials are lost, I have to apply my license key again.
I am using local on-prem n8n installation via docker on Ubuntu 24.04.
My docker-compose.yml file seems to be correct.
When I restart whole Ubuntu machine, the config and all data is persistent after reboot. Data is cleared only when services are manually stopped and started.
Any hints, guys?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Hi @Robert5

What this sounds like to me is a persistence issue rather than n8n clearing data on its own.
In Docker, n8n stores the default SQLite database file and encryption key under /home/node/.n8n, so if that folder isn’t mounted to a persistent volume, or if the container is being recreated against a different/empty mount when you manually stop and start it, you’ll see exactly this kind of “fresh install” behavior with lost users, workflows, credentials, and license data. I’d first check whether your compose file really mounts /home/node/.n8n persistently, and also whether you’re using docker compose stop/start versus something that recreates the container or points it at a different working directory or volume.

1 Like

You’re probably using docker compose down which removes containers and anonymous volumes. Use docker compose stop and docker compose start instead. Also make sure your docker-compose.yml uses a named volume for /home/node/.n8n, not an anonymous one.

Hello,

Thanks for all your replies.

I have created directory /home/node within my / filesystem.

My docker-compose.yml configuration looks like this:

services:
n8n:
image: n8nio/n8n
restart: always
ports:
- “5678:5678”
environment:
- GENERIC_TIMEZONE=“Europe/Warsaw”
- TZ=“Europe/Xwarsaw”
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_RUNNERS_ENABLED=true
- WEBHOOK_URL=“https://my-domain-url”
- N8N_PUSH_BACKEND=websocket

  volumes:
  - n8n_data:/home/node/.n8n

volumes:
n8n_data:

Should be anything (a file, a directory) inside /home/node directory?

What permissions shoud be set for /home/node?

REGARDS

Hi Ben,

Thanks for your tips.

I clear all typos and quotes in .yml file.

Now I am stopping n8n using ‘docker compone stop’ (not down).

It looks like now all my data persits accross all host restarts and starts/stops.

Thank you again!