n8n credentials lost after restart: diagnose, recover safely
Learn how to tell whether n8n credentials vanished, became undecryptable, or sit on missing storage—and recover safely across Docker, SQLite, and PostgreSQL.
n8n credentials usually survive a normal restart. When they seem to disappear, the instance may be using a new or empty database, unable to decrypt records with the current N8N_ENCRYPTION_KEY, or running workers with different storage or key settings. Before restoring, changing keys, or recreating credentials, preserve the database, volume, configuration, key source, and logs.
A restart should not erase n8n credentials—identify the symptom first
A missing credential is an observation, not a diagnosis. The record may still exist while n8n cannot decrypt its secret. It may also be hidden by an account, project, permission, or deployment mismatch. Do not create replacement credentials until you know which case applies.
| What you observe | Likely cause | First safe check |
|---|---|---|
| Credentials and workflows both disappeared | New or empty database, missing volume, or failed restore | Compare database identity, timestamps, and mounted paths with the previous deployment |
| Workflows remain, but credentials fail to load or save | Encryption-key mismatch or damaged credential data | Inspect startup and credential-use logs; preserve the original key |
| One worker fails while another works | Different key, database, data directory, or environment | Compare the effective configuration of every process |
| Credentials exist but are not visible in the editor | UI, permissions, project, or ownership issue | Check the account and project, then review server logs |
| Credentials vanish after container recreation but not a simple restart | Ephemeral storage or a different volume name | Inspect the running container or pod mount and database contents |
A recreated container can start successfully against an empty database. The editor alone does not confirm that persistence works.
Before you start: preserve evidence and check persistence
Before changing configuration, preserve evidence and confirm which storage n8n uses. Capture logs, the running n8n image and version, database settings, mounted volumes, file ownership, and the current key source. Take a database backup or filesystem snapshot first when supported. Never put the encryption key or credential values in a ticket, shell history, or shared log.
- Inspect the n8n startup logs and the logs from the first failed credential use. Look for database connection or migration failures, encryption or decryption failures, permission errors, and messages about a different data directory. A generic successful-start message does not confirm that n8n opened the expected database.
- Confirm the database in use. With SQLite, check the persistent n8n data directory and database file. With PostgreSQL, compare the host, database name, schema, and user with the previous deployment. An external PostgreSQL server does not help if the new container points to a different database or cannot complete migrations.
- Inspect the mounts for the running container or pod. In Docker, compare the actual /home/node/.n8n mount with the expected one. Check whether a newly created named volume has a different name. In Compose, inspect the rendered configuration and the volume on the running container, not only the YAML or .env file you intended to use. In Kubernetes, check the pod mounts, PersistentVolumeClaim, namespace, and pod events.
- Check ownership and access on the mounted directory. A present volume may still be unusable if n8n cannot read or write it. Record permissions before changing them. Check the current n8n documentation for the expected user and filesystem layout of the installed image.
- Compare workflow names, credential records, and recent timestamps in the current database with a known backup or previous snapshot. If the database is empty or much older, stop changing the application and follow the missing-storage recovery path. If records are present but decryption fails, do not restore over them yet.
For a VM installation, check the service working directory and N8N_USER_FOLDER. Do not assume n8n uses the shell user's home directory. For hosted n8n, follow the provider's current backup, restore, export, and support procedures instead of inspecting infrastructure you do not control.
The encryption key must remain unchanged across the deployment
Stored credential secrets, including API keys and OAuth tokens, depend on N8N_ENCRYPTION_KEY. n8n must start with the same key each time. Every process handling the same data must use it too. A changed key can make credentials look deleted, but a new key cannot decrypt records protected by the original.
Keep the key out of ordinary logs and source control. Store it in the deployment's secret manager or another controlled secret store. Keep a protected recovery copy. Settings and precedence can change between n8n releases, so check the current official n8n documentation for the installed version before moving the key.
In Docker, persist the database separately from the container and provide the same key after every recreation. The n8n data directory, commonly /home/node/.n8n in Docker examples, must not exist only on the ephemeral container filesystem. Replacing a container must not silently replace that directory.
In Docker Compose, keep the key in a protected environment or secret mechanism. Use a stable database volume or an external PostgreSQL service. Confirm the rendered service configuration and the actual volume on the running container. Changing .env does not necessarily change an already running container.
In Kubernetes, store the key in a Secret. Inject it consistently into the main n8n process and every n8n-worker. Bind the database and required n8n data directory to persistent storage. Queue mode still requires compatible database access and matching encryption settings across processes.
In hosted n8n, the provider normally manages the internal key and database. If you move data from hosted n8n to self-hosted n8n, do not assume the hosted key can transfer. Plan for credential re-entry unless the provider documents a supported migration path.
Recover the least risky way for the failure you found
Use the recovery path that matches the failure. Keep the affected instance stopped or isolated while preserving its database, volume, configuration, and logs. Reconnect the correct storage or restore the original key before importing or recreating anything.
Missing storage, wrong mount, or ephemeral container
- Preserve the current container, volume list, database connection details, and logs. Snapshot or copy any newly created database before replacing it.
- Reattach the original persistent volume or point the service to the original PostgreSQL database. Correct the mount, namespace, claim, or Compose volume name without deleting the new volume.
- Start one controlled n8n instance. Check whether the previous workflows and credential records return. If they do not, stop and compare database identity and timestamps again instead of creating credentials manually.
If the original storage was never persistent and no usable backup exists, encrypted credential values may be unrecoverable. Preserve the current workflows and configuration before re-entering credentials.
Changed or lost encryption key
- Find the original key in the deployment secret store, protected configuration backup, previous host, or documented recovery copy. Preserve it exactly, including characters that the secret mechanism may treat specially.
- Apply that original value to the main process and every worker. Then restart in a controlled way. A new key can protect credentials saved afterward, but it cannot decrypt values protected by the old key.
- If the original key is genuinely lost, stop before editing the database or changing keys repeatedly. Restore a matching database-and-key backup if one exists. Without the original key or matching backup, n8n cannot normally recover the old encrypted values. Recreate credentials only after preserving the affected workflows and data.
Do not copy decrypted credential files or secrets into chat, tickets, shell history, or temporary public storage. If recovery exposes plaintext, use only the current official n8n procedure. Remove temporary plaintext copies immediately afterward.
One worker has different configuration
- Compare the effective environment and mounted secrets for the main process and every n8n-worker. Check N8N_ENCRYPTION_KEY, database host and name, schema, N8N_USER_FOLDER, and the n8n version.
- Correct the deployment source, Secret, ConfigMap, or Compose definition. New pods and containers must receive identical supported values. Record the old configuration before restarting or rolling the affected processes.
- Remove the failing worker from service while testing a representative queued execution through a working path. If it still fails after correction, inspect its mounted secret and database connectivity instead of changing credentials again.
Validate the recovery
Credentials returning in the editor is useful evidence, but it does not confirm that decryption and execution work. Test a real, low-impact workflow and check every process that may handle it. Then test the restart or rollout method that caused the incident.
- Open a representative credential without exposing its secret value. Run a small, low-impact workflow that uses it. Confirm that the execution succeeds.
- Test one workflow handled by the main process. If you use queue mode, test another handled by a worker. Confirm that the expected credential resolves and no process reports a key or database error.
- Restart one controlled process and repeat the test. Then test the actual container-recreation or pod-rollout method. Stop the rollout if credentials disappear, logs show a different database, or a process reports decryption failure.
- Confirm that all processes use the same database and key without printing either value. Check the persistent volume, PostgreSQL backup status, or SQLite file backup for the installation you run.
Prevent the next restart from repeating the incident
Prevent a repeat by backing up the database and encryption key together. Keep access to both as tightly controlled as production access because the database contains encrypted secrets and operational data. Add a restart check that tests storage, the key, database access, migrations, and a harmless workflow.
Back up the database and encryption key as a matched recovery set. Keep access to both as tightly controlled as production access because the database contains encrypted secrets and operational data.
Add a restart check to deployment changes. It should verify that the expected mount is attached, the key is present, the database is reachable, migrations complete, and a harmless test workflow can resolve a non-production credential.
Before restoring an older backup, snapshot the current instance. Restore the backup into an isolated database or temporary deployment. Compare workflows and credentials before any production cutover so newer data is not overwritten.
Perform a small isolated restore test on a schedule. Record the n8n version, database type, volume layout, secret source, and current official n8n recovery steps. Review them whenever you upgrade or change deployment platforms.
Conclusion
Preserve the current instance first. Then determine whether records are missing, undecryptable, or isolated to one process. Restore the correct storage or original key before recreating credentials. If you restore a backup, test it separately so newer workflows and credentials remain recoverable.
Frequently Asked Questions
How can I tell deletion from an encryption-key mismatch?
Check the expected database, not only the editor. If workflow and credential records are absent, investigate storage or database selection. If records remain but n8n cannot decrypt or use their secrets, preserve the original N8N_ENCRYPTION_KEY and a matching backup before changing anything.
Can I generate a new N8N_ENCRYPTION_KEY to recover old credentials?
No. A new key can protect credentials saved afterward, but it cannot decrypt values protected by the old key. Find the original key or restore a database backup paired with it. If both are lost, preserve the data and plan to recreate credentials.
Why do credentials work in one n8n worker but not another?
The workers may use different encryption keys, databases, data directories, versions, or other environment settings. Compare their effective configuration and mounted secrets. Remove the failing worker from service while correcting the deployment, then test a representative queued workflow.