n8n Credentials Could Not Be Decrypted: Find the Original Encryption Key
Diagnose n8n credential decryption errors after a restart, restore, or deployment change by checking the saved instance key, persistent data, and every worker before changing secrets.
Updated 2026-11-27•Verified 2026-11-27•Checked against 10 sources•11 min•Exact error fix
“Credentials could not be decrypted. The likely reason is that a different encryptionKey was used to encrypt the data.”
Short answer: This is usually a mismatch between the key n8n is using now and the instance key that protected the stored credentials. Treat the database and its original key as a pair. Before restarting, migrating, or rotating anything, identify which data directory, database, environment secret, and worker processes the running instance actually uses; restore the original key from the deployment configuration or a known-good backup whenever possible.
What the decryption error tells you—and what it does not
n8n stores credential fields in encrypted form. When it opens a credential, it must use the instance encryption key associated with that saved data. If the application now reads the same database but loads a different key, the ciphertext cannot be opened and the UI reports a decryption failure. The wording points toward key or data-directory mismatch; it does not prove that an API password is wrong, that the third-party service revoked access, or that every credential must be recreated.
Start by noting which records fail and what changed immediately beforehand: container recreation, volume remount, database restore, host migration, environment-secret edit, scale-out, or version change. If every older credential fails after one deployment event but a newly created credential works, that is strong evidence that the running instance is using a key different from the one protecting the older records. Preserve logs and deployment history before changing the configuration again.
Confirm the database and the persistent n8n data directory
The same saved instance key must follow the n8n database through a restart or restore.
On a default installation, n8n generates an encryption key on first launch and saves it in its user folder, normally under `~/.n8n`. The official Docker example mounts persistent storage at `/home/node/.n8n`; replacing a container is safe only when the intended data volume remains attached. With PostgreSQL, the database is external, but the `.n8n` directory still contains important information such as the encryption key. Restoring only the database can therefore leave workflows present while the key needed to open their credentials is missing or unrelated.
Compare the running deployment with the last known-good configuration. Confirm the database host and name, n8n user folder, mounted volume, and whether `N8N_ENCRYPTION_KEY` is set. Check the actual container or process configuration through the deployment platform’s protected settings; do not paste the key into a terminal transcript, screenshot, support ticket, or shared log. A compose file that names a volume is not enough by itself: verify that the restarted service mounted the same volume and path.
If you configured `N8N_ENCRYPTION_KEY`, verify that its protected secret version is the one expected for this database. Compare secret names, deployment revisions, and timestamps rather than printing key material. If the variable is absent, inspect the mounted n8n user folder and its config file using access controls that do not expose the value. A common failure pattern is a new container with a fresh empty data volume: it generates a new key, while the database still contains credentials written under the previous one.
Also rule out a different instance or database being opened in the browser. A staging environment can point at a production database, or a restored database can be paired with the wrong deployment secret. Compare the secret reference or version identifier in your approved secret manager without printing or exporting the key. If you cannot establish which key protected the database, stop before trying possible values in production.
In queue mode, compare the main process and every worker
Main, worker, and webhook processes must use the same instance key and database.
A queue deployment has several n8n processes sharing a database and Redis. The main process receives triggers and queues executions; workers load workflow and credential data to execute jobs. n8n requires the main instance’s encryption key to be shared with all worker and webhook-processor nodes. If the editor opens credentials but jobs fail on a worker—or only one worker fails—compare the protected key version, database connection, user folder, and n8n version across all processes before changing the credential itself.
A rollout can temporarily leave old and new worker containers running with different secret revisions. Check the orchestrator’s desired and actual replica state, deployment events, and worker logs. Bring the fleet back to one known-good configuration using the same key and database, then run one controlled workflow. Do not “fix” a single worker by generating a new key; that can create a second incompatible state and make the failure intermittent.
Recover the original key without overwriting encrypted data
Look first in the deployment’s secret manager, environment history, infrastructure configuration, or protected backup of the n8n user folder. Restore the key that belongs to this database, then restart the relevant processes in a controlled way. If the database and user-folder backup were captured together, restore them together into an isolated recovery environment and confirm that older credentials open there before changing production. Treat database snapshots and key backups as equally sensitive because the key can unlock stored integration credentials.
If the original key is unavailable, preserve a full database backup and the current n8n data directory before attempting recovery. Do not delete credential rows, bulk re-save blank credentials, switch repeatedly between candidate keys, or rotate the master key in place as a guess. Re-entering each third-party secret may be possible in some cases, but it is a migration plan with business impact, not the first diagnostic step. Establish what data is recoverable and test the procedure on a copy.
Do not confuse key rotation with changing the master key
A recovery decision path that starts with a backup and the original key instead of overwriting secrets.
Changing `N8N_ENCRYPTION_KEY` is not the same as using n8n’s supported encryption-key-rotation feature. Current n8n documentation describes a two-layer model: the instance key remains the master key, while a data encryption key can rotate under it. The documented rotation path has version and backup requirements, and data written in a newer format may not be readable after a downgrade. Follow the current migration instructions for the exact version in use; never improvise a database update or make an environment-variable change simply because the credentials error mentions a key.
Before a planned rotation or major upgrade, take a full database backup, confirm all main and worker processes share the same instance key, and test the change on a staging copy. Verify that the old credentials decrypt before and after the change, and document the rollback limit. If an upgrade itself appears to cause the error while the secret and data mount are unchanged, check the exact n8n release notes and a minimal restored reproduction; do not assume the log text proves a genuine key mismatch.
Keep the database, key, and deployment record together
A reliable backup plan records which database snapshot belongs with which n8n user-folder backup and protected secret revision. Keep secret material in a secrets manager or an access-controlled backup process, not in a repository or a plain-text operations note. Test restoration in an isolated environment periodically: a backup is only useful if the database, key, n8n version, and required storage can be paired again. For queue deployments, include the same key revision for the main process, workers, and webhook processors.
Before a routine redeploy, verify persistent-volume identity and secret references in the deployment diff. After startup, confirm the instance is using the intended database and that representative older credentials can be opened before resuming high-impact workflows. If credentials decrypt but a particular API connection fails, then move to the provider-specific authentication checks; this error and an HTTP 401 are different layers and should not be debugged as one problem.
Record the n8n version, database snapshot ID, user-folder backup, and secret revision as one recovery set.
Use a persistent volume or an explicitly managed custom key; do not let replacement containers silently create unrelated instance state.
Set the same master key on every main, worker, and webhook process in queue mode.
Test restoration and key rotation in a copy before changing the production database.
Documentation and source notes
The recovery sequence follows n8n’s current deployment, Docker, queue-mode, and key-rotation documentation. Product-version behavior can change; compare the instructions with the exact n8n version and deployment type you operate before carrying out a migration. The links below are the primary references for generated keys, persistent data, shared worker keys, and rotation safety.
Can I fix “Credentials could not be decrypted” by reconnecting the API account?
Not usually as the first step. This message means n8n cannot open the stored encrypted credential with the key currently loaded. Confirm the database, user folder, and original encryption key first. Recreate a provider credential only after you understand whether existing encrypted data is recoverable and have a tested backup.
Where does n8n keep its generated encryption key?
By default, n8n creates a key on first launch and saves it in the n8n user folder, normally `~/.n8n`. In Docker, the persistent volume mounted to `/home/node/.n8n` is important. A PostgreSQL deployment still needs this directory or a deliberately managed custom key, because the database alone does not contain every required instance setting.
Do all queue workers need the same N8N_ENCRYPTION_KEY?
Yes. n8n’s queue-mode documentation says the main instance key must be shared with workers and webhook processors that read credentials from the same database. A partial secret rollout can make failures appear intermittent because only jobs assigned to a mismatched process fail. Compare protected secret revisions across the whole deployment.
Should I change the encryption key after a credential decryption error?
Do not replace it as a guess. First recover the original key associated with the stored database or restore a paired backup in a test environment. Planned data-key rotation is a separate documented feature with version, backup, and rollback requirements; changing the master key in place can leave existing credentials unreadable.