Why n8n encryption key management decides whether your credentials survive
A self-hosted n8n instance stores its API keys, OAuth tokens and database passwords in its own database, and every one of those credentials is encrypted with a single key. That encryption key is the point everything else depends on: if it is present, correct and consistent across the instance, your workflows keep running; if it is lost, altered or mismatched, the stored credentials cannot be decrypted and must be re-entered by hand. Setting, storing, rotating and backing up that key is therefore a security and operations decision to make before go-live, not a detail to revisit after the first incident.
Teams need this work at several points. The first production deployment is the obvious one, because the key must be fixed before real credentials are saved. Queue mode with worker and webhook processor nodes is another, since the key must be shared with every process that reads credentials from the database, so distributing it safely becomes a design task rather than a copy-and-paste. A security review usually asks where the key lives, who can read it and whether it is covered by backups. A planned rotation may follow staff changes or a suspected exposure of a secret. The key is supplied through the N8N_ENCRYPTION_KEY environment variable, and the exact behavior of rotation depends on the n8n version you run, so confirm the steps against n8n's queue mode documentation and your version's release notes before you plan any change.
Before you start, ask who owns the key, where the authoritative copy is held outside the n8n host, and how a restore would retrieve it. Ask your implementation partner or internal team to document the rotation procedure for your version, to rehearse a restore from backup in a non-production environment, and to confirm which processes need the key. These checks decide whether a server failure or a departing administrator becomes a routine recovery or a loss of every stored credential.
Where the encryption key can live and which option fits
This table compares four places to hold N8N_ENCRYPTION_KEY, with the fit, main risk and ongoing work for each. Read each row against your topology, since a key that is easy to manage on one host can become a single point of failure across queue mode workers. Confirm the supported loading method with n8n before you commit to a secret manager.
| Storage option | Best fit | Main risk | Ongoing operational work |
|---|---|---|---|
| Plain environment variable in a compose file or unit file | Small single-host test or pilot with no real credentials | Key visible in configuration repositories, process listings and host backups | Low day to day, but every copy of the file must be found and updated at rotation |
| Kubernetes Secret injected at runtime | Single-cluster production where the cluster already has access controls | Base64 is not encryption, so anyone with read access to the namespace or etcd backups can read the key | Maintain RBAC on the namespace, encrypt etcd at rest and keep manifests out of Git |
| External secret manager that injects the value at startup | Regulated production where the key must be reviewed and rotated under central control | n8n may not read this store directly, and an outage at startup can stop every main, webhook and worker process | Set up the sync or injection layer, health checks and tested restart behavior; confirm the supported loading method with n8n |
| Hardware or cloud key service | Organizations with an existing HSM or cloud key service and a formal key custody policy | Integration depends on the key service being reachable and on n8n using the key the same way in every process | Plan access grants, key policy and audit reviews; confirm with n8n whether the key can be wrapped or loaded this way |
How the key moves from the secret store to main, workers and the database
The key starts in a secret store that your team controls, and the deployment step injects it as N8N_ENCRYPTION_KEY into the main instance. The same value must reach every worker and webhook processor, because each of them decrypts credentials read from PostgreSQL. The database only ever holds encrypted credential records, so a copy of the database without the key is not enough to recover secrets. Check that each process receives an identical key, and that the secret store is the only place the value is written down.
The encryption key is copied into each process that reads credentials, while the database stores only ciphertext.
Setting N8N_ENCRYPTION_KEY and moving it into a secret manager
This sequence generates the key that protects every stored n8n credential, places it in a secret manager with a named owner, and injects it into the main instance and every worker and webhook processor at startup. Each step ends with a check so a mismatch or leak is caught before the instance takes real traffic.
Generate a high-entropy encryption key
The platform owner generates the key with an approved random generator on a trusted workstation, not in a shared chat, ticket or script committed to a repository. Confirm the exact length, character set and format the key must have in n8n's documentation for the version you run, because the accepted format is version-specific. Record the generation date, the generator used and the person who produced the value in your change record, but never the value itself. The step is done when the value exists only in the approved secret manager and the generation record is filed.
Store the key in the secret manager
Create a secret entry in your secret manager (for example, a self-hosted OpenBao or another approved store) with a named owner, a description that names the n8n instance it protects, and an access policy limited to the platform team and the workloads that run n8n. Separate paths or namespaces for production and non-production keys prevent a staging instance from reading production credentials. Confirm that read access is logged and that administrators can see the access history. The step is done when a test read by an authorized identity succeeds and a read by an unauthorized identity is denied and logged.
Inject the key at startup, not in files
Configure the deployment so the platform injects
N8N_ENCRYPTION_KEYinto the container environment at startup, using your orchestrator's secret mechanism or an init process that reads from the secret manager. Keep the variable out of Compose files, Helm values, Dockerfiles, image layers and.envfiles tracked by version control. Add a pre-commit or repository scanning rule that blocks the key pattern and the variable name with a value attached. The step is done when a fresh deployment starts with the value present in the process environment and a repository scan finds no match.Set the same key on the main instance
Set the injected variable on the main instance first, then start it against the existing database. If the instance was already running with a key, the value must match the key that encrypted the stored credentials, which means you must not replace it without the rotation procedure. Open the editor and confirm that existing credentials still open and that a credential-using test workflow runs from the main instance. The step is done when a stored credential decrypts in the editor and the test workflow completes without a decryption error.
Set the same key on every worker and webhook processor
In queue mode, the main instance's key must also be present on every worker and webhook processor because those processes read credentials from the database. Apply the same secret reference to each worker and webhook processor deployment, including any added later by autoscaling, so that no process starts without it. Run a credential-using workflow with its execution routed to a worker, then trigger a webhook handled by a webhook processor. The step is done when both executions succeed and no process logs a decryption failure.
Start the stack and verify key handling
Start the full stack in a staging environment first, then production, and run the checks in a fixed order: credentials open in the editor, workers execute credential-using workflows, and webhook processors do the same. Inspect repositories, application logs, container logs and container inspection output for the key value or a fragment of it, and confirm your log shipper filters it. Restrict who can run container inspection commands in production. The step is done when the three functional checks pass and a documented search finds the key nowhere outside the secret manager.
How the two-layer rotation model affects planning
Rotating the n8n encryption key is two jobs, not one, and planning has to treat them separately. The first layer is the value itself: every process that reads credentials must be given the new key. The second layer is the data: the credentials already stored in the database must be re-encrypted or re-keyed so they stay readable under the new key. These layers can fail independently. The key can be updated on the main instance while stored credentials are still encrypted under the old value, or the data can change while one process still holds the old key. Each layer needs its own step and its own check.
Queue mode makes the first layer harder. The main instance's key must be shared with every worker and webhook processor so they can read credentials from the database, so a rotation that updates the main instance but misses one worker will produce failures that appear only when that worker runs a credentialed node. Plan a maintenance window long enough to cover the full sequence, decide whether triggers and schedules are paused during the change, and write down the order in which main, workers and webhook processors are updated. Take a verified backup of the database and the current key before starting, and define the rollback path. After the change, run a test execution on each worker type and confirm that a sample of credentials from different node types decrypts and authenticates.
The exact layer behavior, the supported rotation commands and any downtime requirement depend on the n8n version in your environment, and n8n ships minor releases roughly weekly. Confirm these details in the n8n documentation for that version before a production rotation is scheduled, and rehearse the full sequence in a staging copy that uses the same queue topology. The n8n queue mode documentation is the starting point for confirming which processes need the shared key. If the documented procedure differs from the plan in this section, the documented procedure for your version governs.
Backups before rotation and what a lost key means
Rotating or losing the n8n encryption key affects every stored credential at once, so the backup and key custody steps come before any change. The cards below cover what to capture first, how long the old key stays available, and what happens to credentials and restored data when the key no longer matches.
Consistent database backup first
Credentials live in the database in encrypted form, so a backup is only useful if it was taken as a consistent snapshot that matches the key in use at that moment. Take the database backup while n8n is quiet or stopped, and record the timestamp alongside the key version it corresponds to. Owner: the platform team running the database. Check that the restore procedure has been run at least once in a separate environment before rotation begins.
Queue mode docsSeparate, access-controlled key copy
Keep a copy of the current N8N_ENCRYPTION_KEY in a location separate from the database backup, such as a secret manager entry with its own access policy. Only the small group who can perform a restore should read it, and every read should be logged. Owner: the security team, with the platform team as approvers. Confirm the copy is still present and readable before the rotation window opens.
Keep the old key until verified
Rotation is only safe when the old key can still decrypt credentials until every workflow has been tested against the new key. Do not delete or overwrite the previous key value on the day of the change. Owner: the platform engineer running the change. Hold the old key for the full verification window agreed in the change plan, then retire it under a recorded decision.
What a lost key means
Stored credentials cannot be decrypted without the key that encrypted them, so every API token, password and OAuth connection in n8n becomes unusable. Workflows that depend on those credentials stop until each one is re-entered and tested. Owner: the platform owner, who must know which workflows depend on credentials. Keep an inventory of credential names and their owning workflows so the re-entry effort is known in advance.
Restoring a backup with a different key
A database backup encrypted under one key will not decrypt under another, so restoring an older backup after a rotation can break credentials that were valid at the time of the backup. Match each backup to the key that was active when it was taken before any restore. Owner: the operator performing the restore. Include the key version in the backup record so a restore never pairs data with the wrong key.
Key copies outside general archives
General backup archives are often readable by many administrators and retained for long periods, which makes them a poor place for the encryption key. Store the key in the secret manager and exclude it from file-level and volume-level backups of the n8n host. Owner: the backup administrator. Review the backup job definitions to confirm no environment file or container configuration holding the key is included.
OpenBao or HashiCorp Vault as the secret store for the key
OpenBao is a community fork of Vault released under the MPL-2.0 license. It is managed by a community under open-governance principles and is a Sandbox project of the Open Source Security Foundation (OpenSSF) under Linux Foundation stewardship. It provides encrypted key/value storage, dynamic secrets, encryption as a service, leasing with automatic revocation and a range of auth methods, including AppRole, JWT/OIDC, Kubernetes and TLS certificates. Its documented storage backends are integrated storage (Raft), PostgreSQL, PebbleDB and in-memory, with integrated storage and PostgreSQL as the officially supported high availability backends.
- License and governance: MPL-2.0 applies to the repository, so review the license with your legal team before you rely on it for internal use.
- Storage and HA: Choose integrated storage or PostgreSQL for high availability. The docs describe PostgreSQL as easier to operate safely than Raft.
- Auth for servers: OpenBao recommends AppRole for servers, which suits an n8n main instance and its workers.
- Version gap: The migration guide was tested only against Vault 1.14.1 community edition. Confirm behavior for the exact OpenBao release you deploy, such as v2.7.1, in a staging environment.
- Recurring work: Your team owns upgrades, backups, unseal and recovery procedures, and any support contract you negotiate separately.
Confirm with your security team which auth method and storage backend fit your standards before you build the key retrieval path.
Vault Community Edition is offered as binaries or source. Starting with Vault 1.15.0, releases are licensed under the Business Source License 1.1, which HashiCorp announced on August 10, 2023. The Vault LICENSE names IBM as licensor, following IBM's acquisition of HashiCorp, which completed on February 27, 2025. The license bars competitive hosted or embedded offerings and converts each version to MPL-2.0 four years after publication. Your internal use of the secret store for n8n is a different question from building a competing product, so have legal confirm the terms apply as you expect.
- Storage and HA: HashiCorp recommends integrated storage (Raft) for most use cases. Consul is the other officially supported backend. PostgreSQL, MySQL, DynamoDB and S3 have limited support.
- Enterprise features: Features such as HSM support, seal wrapping, namespaces and FIPS compliance need a licensed Enterprise cluster, so do not assume the Community binary includes them.
- Current release: Vault 2.2.0, released on October 15, 2026, is the current release, following 2.1.2 on October 7, 2026. Check which line your key store uses and plan upgrades against it.
- Ownership: Your team operates the cluster, including backups, unseal keys and monitoring.
- Pricing: Community Edition has no license fee, but staff time and infrastructure remain costs.
Confirm the Vault version and license terms in writing with your legal and procurement teams before you standardize on it.
Vault Enterprise is a licensed edition that adds features such as performance and disaster recovery replication, HSM support through a PKCS#11 provider, namespaces, performance standby nodes, seal wrapping, FIPS compliance, control groups, Sentinel policy as code, redundancy zones, automated upgrades, lease count quotas and MFA. These features require a license applied to the cluster. HCP Vault Dedicated is a managed service that runs the same binary as self-managed Vault Enterprise. HashiCorp's pricing pages describe pay-as-you-go, flex and Enterprise self-managed commercial models and direct self-managed Enterprise buyers to sales. Vault Enterprise prices are not published, so ask for a written quote.
- Pricing model: Ask whether the quote covers the self-managed license, HCP usage, support tier and any replication or HSM add-ons you need.
- Replication and DR: If your n8n environment spans sites, confirm which replication mode and recovery procedure the license covers.
- Managed versus self-managed: HCP Vault Dedicated moves operating tasks to the provider. Confirm where the key material and audit logs reside and who can access them.
- Support: Ask what response commitments are written into the contract and whether they are described as an SLA.
- Data location: Confirm that HCP deployment regions meet your residency rules before the key is stored there.
Confirm with HashiCorp sales which features, regions and support terms are included, and get them in writing before you size the deployment.
What to confirm before you rotate the key in production
Rotating the n8n encryption key touches every stored credential, so the procedure has to be confirmed against your exact version, topology and secret store before anyone runs it. The cards below list what to verify, who answers each question and where the answer usually comes from.
Rotation procedure for your version
Confirm the exact rotation steps and which layers your n8n release supports, because the two-layer model changes what you must re-encrypt. Ask n8n support or check the release notes for the version you run, and get the steps in writing before scheduling a window. Do not rely on steps copied from an older guide or a forum post. Ask whether the procedure has been tested on a copy of your production database.
n8n release notesRestart and downtime requirements
Ask whether the main instance must restart after the key changes, and whether executions in flight will fail or resume. Find out how long credentials remain unreadable during the switch and whether webhooks return errors in that window. Your platform team owns the answer for your deployment method, so confirm it against a staging environment that mirrors production load. Write the expected impact into the change request.
Queue mode worker updates
In queue mode, every worker and webhook processor must receive the same encryption key as the main instance, or they cannot read credentials. Confirm the order of operations so that no node runs with a stale key during the change. Ask your deployment team which workers run on which hosts or pods and how each receives the new value. Check that no worker keeps an old copy in a cached configuration file.
Queue mode docsSecret store startup dependency
If you load the key from a secret manager at startup, confirm what happens when that store is slow or unreachable during a restart. A failed read can stop n8n from booting, which turns a secret store outage into a workflow outage. Ask the platform team whether the store runs in the same failure domain as n8n and whether the startup path has a documented fallback that does not weaken key protection.
Vault or OpenBao migration guide fit
Confirm that any migration guide you plan to follow was tested against your exact product and edition. The OpenBao migration guide was tested only against Vault 1.14.1 Community Edition, not Vault Enterprise, so an Enterprise cluster needs its own validation. Ask your secret store administrator which version and edition you run and whether they will sign off on the path. Record the result in the change plan.
OpenBao migration guideBackup and recovery sign-off
Confirm who approves the backup taken before rotation and how a restore is tested. Ask the database owner whether the backup includes the credentials table and whether it can be restored into a separate environment to verify the old key still decrypts it. Ask the security owner who holds the previous key during the rollback window and when it is destroyed. Keep these answers with the change record.
Questions teams ask about n8n encryption key management
What drives the effort to set up and rotate the n8n encryption key?
The effort depends on how many n8n instances share the key, where the key is stored today, and how many workers and webhook processors must receive it. A single instance with the key in a file needs a short change, while queue mode with several workers means every process that reads credentials must be updated in the same planned window. Rotation effort also grows with the number of credentials, the backup and restore process you already have, and whether a staging copy exists to rehearse the change. Ask any partner to show how they will inventory every node that holds the key before they quote.
Can our own staff set up and rotate the n8n encryption key?
Yes, if your team has administrative access to the n8n hosts, the database and the secret store, and can follow a tested runbook. The work is mostly configuration and sequencing, but mistakes are costly because a wrong key makes stored credentials unreadable. Teams without recent n8n operations experience usually benefit from a written rotation plan, a staging rehearsal and a second reviewer before the production change. A partner can plan and run that work under a fixed-scope agreement, or review the plan your staff write.
What does DeployOpen need from our team to work on the key?
Typically the partner needs access to the n8n hosts or container platform, administrator rights in the secret manager that will hold the key, and a maintenance window agreed in advance. A staging copy of the instance, including its database, lets the change be rehearsed before production is touched. Your team should also confirm who approves changes, who holds the current key material and how backups are taken and restored. These items are listed in the written scope so both sides know what is provided and what is received.
Can we recover credentials if the n8n encryption key is lost?
Usually not. n8n uses the encryption key to decrypt stored credentials, so without the original key the encrypted values in the database cannot be read back, and any backup encrypted with the same key is equally unreadable. Recovery depends on having a copy of the key in a controlled secret store or a secured backup taken with it, and on the ability to re-enter credentials in the affected workflows. Store the key in at least one place outside the n8n host before any rotation, and test a restore on staging so you know the key and backups match.
Do we need a secret manager to protect the n8n encryption key?
A secret manager is not strictly required, but it is the most common way to keep the key out of configuration files, shell history and container images while still making it available at startup. Self-managed options include HashiCorp Vault under its Business Source License, and OpenBao, a community fork under MPL-2.0 that is managed by the Linux Foundation's OpenSSF. Confirm licensing, supported storage backends and the features your team needs before choosing either, since HashiCorp's pricing for self-managed Enterprise is only available through sales. Whatever you choose, restrict who can read the key and log every access.
How is a fixed-scope n8n key engagement priced and quoted?
A fixed-scope engagement is priced from a written scope that lists the instances in play, the hosts and queue components affected, the secret store work, the staging rehearsal, the backup verification and the handover documentation. The quote separates one-time work such as planning, the first rotation and documentation from any recurring work such as periodic rotation drills or ongoing support, which is offered as a retainer. Ask for each deliverable and its acceptance check to appear in the quote, and ask what changes the scope and how additional work is priced. DeployOpen does not publish a price list, so the quote follows from the agreed scope.
How DeployOpen scopes and delivers n8n encryption key management and rotation
DeployOpen treats the n8n encryption key as a controlled asset with its own owner, storage location and rotation runbook. We scope the work in writing, build the key handling in your infrastructure, test restore and rotation before go-live, and hand over documentation your operations and security teams can run without us.
How we scope
- Confirm which n8n instances, workers and webhook processors hold the encryption key and need it in queue mode
- Agree which secret manager or vault platform stores the key and who administers it
- Define the key owner, access approvals, rotation cadence and the backup point required before any rotation
- Record the scope in writing before work starts, since most engagements are fixed-scope
How we build
- Set N8N_ENCRYPTION_KEY from the secret store on the main instance and every worker and webhook processor
- Document the two-layer rotation model so the key and any database-level re-encryption steps are sequenced correctly
- Take and verify backups of the database and key material before each rotation, then test a restore in staging
- Test credential access on every node type after a rotation rehearsal and record the results
How we hand over
- Deliver a runbook covering key storage, access, rotation, backup, and what to do if the key is lost
- Provide a record of which systems hold the key and how each copy is protected and audited
- Walk your platform, security and compliance teams through the procedure and the evidence it produces
- Hand over a list of questions to confirm with n8n for your version and plan before the next upgrade
How we support
- Offer ongoing key rotation support, upgrades and continuous testing as a retainer if you want it
- Retest key handling after n8n upgrades, node changes or changes to your secret manager
- Keep runbooks current as your secret platform, n8n version or team responsibilities change
- Scope any follow-on security review of the key path as a separate written engagement

