Persistent bad decrypt Error with Credentials Even After Complete Environment Reset and Correct Encryption Key Configuration

I am encountering a persistent error:03000064:digital envelope routines::bad decrypt error when creating or accessing any credentials (e.g., Header Auth) in my n8n instance. The error occurs after a seemingly successful startup, and all credentials become unusable. This happens even after a complete “nuclear” reset of the environment with a freshly generated encryption key.
Deploy Mode:Docker Compose
Image:n8nio/n8n:latest (also observed on a freshly pulled latest version)
docker-compose.yml’s content:
environment:
N8N_ENCRYPTION_KEY: VdRfC/aOFBfltfzB9D38kp…DATeLi66FRwik=
N8N_PROTOCOL: https
N8N_HOST: 0.0.0.0

… other settings

volumes:

  • ./n8n_data_fresh_final:/home/node/.n8n # A brand-new, isolated data directory
    Additional Information(log snippet):
    error:03000064:digital envelope routines::bad decrypt
    Credentials could not be decrypted. The likely reason is that a different “encryptionKey” was used to encrypt the data.

Hey @Xiaohu !

I don’t know for sure, but this it may be related to

“a misalignment between the encryption key set via Docker environment variables and the key embedded in the persisted configuration (config) file”

Here more informations :

Hope this helps!

Cheers!

Thank you!@Parintele_Damaskin I have mounted the n8n_data directory on the host to the container using - ./n8n_data:/home/node/.n8n in docker-compose.yml. I have also checked the content of the config file located at /home/node/.n8n/, which is: { “encryptionKey”: “VdRfC…Rwik=” }. The key value here is consistent with the encryption key set in docker-compose.yml, but the ‘bad decryption’ issue still persists. Does this mean that the problem I am encountering is not caused by this reason?

I would delete the config file, and keep the env variable.

Since you gave a fresh start, it should work.

But here the LEGEND itself explains exactly this error you got.

Cheers!

I tried to retain the encrypted environment settings but deleted the config under the .n8n directory and restarted the system. I found that the system worked normally but the problem persisted. Then I pulled a brand-new n8n image and started the system with the simplest configuration, and this error still existed. Even installing the non-Docker version was not exempt, so I suspect this is a hidden BUG in the community version. Below is the detailed content of the abnormal results when executing nodes that require Header Auth authorization authentication:

Credentials could not be decrypted. The likely reason is that a different “encryptionKey” was used to encrypt the data.
From HTTP Request
Error extra
{ “name”: “Header Auth account”, “type”: “httpHeaderAuth”, “id”: “YzVpudTBPWKdyn3F” }
Other info
n8n version
2.1.4 (Self Hosted)
Stack trace
Error: Credentials could not be decrypted. The likely reason is that a different “encryptionKey” was used to encrypt the data. at Credentials.getData (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/credentials.ts:57:10) at CredentialsHelper.getDecrypted (/usr/local/lib/node_modules/n8n/src/credentials-helper.ts:359:43) at ExecuteContext.getCredentials (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/node-execution-context/node-execution-context.ts:397:31) at ExecuteContext.getCredentials (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/node-execution-context/base-execute-context.ts:99:10) at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:175:24) at WorkflowExecute.executeNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1045:8) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1226:11) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1662:27 at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2274:11

It could be special char in ure enc key when decryping maybe having issues? Based on ure inital comment it seems successfull… try dont set a key in dockers, n8n will make one automatically in config, then save that enc key in ure dockers etc. Hopefully that gets you up and running. :money_mouth_face: where ure db stored..you using same db?