self hosting
n8n Docker Volume Persistence: Avoid Losing Workflows and Credentials
Persistent Docker storage is mandatory for self-hosted n8n because workflows, credentials, settings, and the default SQLite database live under the n8n user data directory.
Match your incident first
Start with the symptom you can prove
Container restarts after upgrade or compose pull
First check: Run docker compose ps and inspect the last 100 n8n log lines.
Wrong fix to avoid: Do not delete volumes to make the container start.
Verify: Container stays healthy and existing workflows/credentials remain visible.
Workflows disappear after recreating container
First check: Check compose volumes and whether /home/node/.n8n is persisted.
Wrong fix to avoid: Do not create new workflows until you confirm whether old data exists in a volume or backup.
Verify: A restart preserves workflows, credentials, executions, and settings.
Production URL is wrong in Docker deployment
First check: Inspect only the public URL-related env vars and the proxy route.
Wrong fix to avoid: Do not expose the container directly on the public internet to bypass proxy config.
Verify: Webhook URLs in the editor use the intended HTTPS domain.
- Use when
- self-hosted, Docker
- First check
- Confirm workflows and credentials survive a restart before sending real traffic.
- Time to check
- 5-10 minutes
- Next step
- Match the symptom, then run the verification checks.
Independent third-party notes. n8n is a trademark of its owner and is referenced only for compatibility and troubleshooting context.
Quick Answer
Persistent Docker storage is mandatory for self-hosted n8n because workflows, credentials, settings, and the default SQLite database live under the n8n user data directory.
Does this match your symptom?
Self-hosted Docker setup looks risky
The instance runs, but persistence, .env files, public URLs, HTTPS, Postgres, or backups are unclear.
First check: Confirm workflows and credentials survive a restart before sending real traffic.
Problem Pattern
The user recreated or updated a container and workflows, credentials, SQLite data, or community node packages disappeared.
Version awareness
Last reviewed 2026-05-21
Key Facts
- Important path
- /home/node/.n8n inside the official container.
- Default SQLite file
- ~/.n8n/database.sqlite for self-hosted SQLite setups.
- Community nodes path
- ~/.n8n/nodes for installed community packages.
- Main risk
- Recreating a container without the right volume can lose data.
Production Diagnostic Matrix
Turn checks into a brief| Exact symptom or log | Likely cause | First check | Wrong fix to avoid | Verification |
|---|---|---|---|---|
| Container restarts after upgrade or compose pull | Missing required env var, incompatible database migration, or invalid compose service config. | Run docker compose ps and inspect the last 100 n8n log lines. | Do not delete volumes to make the container start. | Container stays healthy and existing workflows/credentials remain visible. |
| Workflows disappear after recreating container | n8n data was stored inside the container instead of a persistent volume or external database. | Check compose volumes and whether /home/node/.n8n is persisted. | Do not create new workflows until you confirm whether old data exists in a volume or backup. | A restart preserves workflows, credentials, executions, and settings. |
| Production URL is wrong in Docker deployment | WEBHOOK_URL, N8N_HOST, N8N_PROTOCOL, or reverse proxy labels are missing or inconsistent. | Inspect only the public URL-related env vars and the proxy route. | Do not expose the container directly on the public internet to bypass proxy config. | Webhook URLs in the editor use the intended HTTPS domain. |
| Database or volume permission errors after moving hosts | File ownership, mounted path, or Postgres credentials changed during migration. | Check volume mount paths, container UID expectations, and database auth logs. | Do not chmod everything recursively without a backup. | n8n starts and can read previous workflows after one restart. |
| Backup exists but restore does not work | Backup missed the database, .n8n folder, encryption key, or binary data storage. | Verify restore in a disposable environment before touching production. | Do not assume a SQL dump alone is enough when binary data or SQLite is used. | A restored test instance can open workflows, decrypt credentials, and run a smoke test. |
| Upgrade breaks a previously working workflow | Node behavior, credential schema, API response shape, or custom node compatibility changed. | Compare failing execution before/after upgrade and check release notes for affected nodes. | Do not immediately downgrade without checking database migration and rollback safety. | Smoke tests for triggers, credentials, expressions, and outbound calls pass on the target version. |
Recommended Steps
- Create a named Docker volume or host bind mount for n8n data.
- Mount it to /home/node/.n8n in the n8n container.
- If using community nodes, ensure ~/.n8n/nodes is also persistent.
- Restart the container and create a test workflow.
- Recreate the container and verify the workflow remains.
Verification
- The same workflows appear after container recreation.
- Credentials remain available after restart.
- Community nodes still load after rebuilding the container.
First Commands / Checks
docker compose ps docker compose logs n8n --tail=100 docker compose exec n8n printenv WEBHOOK_URL N8N_HOST N8N_PROTOCOL N8N_EDITOR_BASE_URL Safe Copyable Config
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_HOST=automation.example.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://automation.example.com/
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data: # Backup Postgres in a private shell
docker compose exec postgres pg_dump -U n8n_app n8n > backup-n8n.sql
# Record non-secret runtime facts
docker compose ps > backup-services.txt
docker compose exec n8n printenv WEBHOOK_URL DB_TYPE N8N_BINARY_DATA_MODE > backup-runtime-public.txt
# Restore only into a disposable test environment first
psql "postgresql://n8n_app:REDACTED@postgres:5432/n8n_restore" < backup-n8n.sql Warnings
- Container filesystem storage is not a backup strategy.
- Back up both the n8n data directory and any external database.
Best For
- Docker users who want workflows and credentials to survive container replacement.
- Teams using the default SQLite database in a containerized setup.
- Instances that install community nodes and need package files to persist.
Not For
- Disposable one-command demos where losing data is acceptable.
- Managed n8n Cloud deployments.
- Users who have already moved all durable data into managed external services and documented that setup.
Common Mistakes
- Mounting the wrong host directory or container path.
- Backing up the Compose file but not the actual Docker volume.
- Persisting workflows but forgetting community node packages.
- Deleting a named volume during cleanup and losing SQLite data.
Examples
volumes:
n8n_data:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
volumes:
- n8n_data:/home/node/.n8n 1. Create a test workflow.
2. Restart the container.
3. Confirm the workflow still exists.
4. Recreate the container without deleting the volume.
5. Confirm credentials and community nodes still load. FAQ
What data is at risk without a volume?
On a default self-hosted Docker setup, workflows, credentials metadata, settings, SQLite data, and community node files may depend on persistent user data.
Is a Docker volume a backup?
No. A volume helps persistence, but a backup must be copied elsewhere and tested with a restore.
Do I still need this if I use Postgres?
Yes. Postgres moves database persistence out of the container, but user data, encryption key handling, and community node files still need planning.