Enforcing two-factor authentication in n8n

Enforcing 2FA in n8n covers the instance setting, recovery codes, how SSO users are treated and when to turn 2FA off instance-wide with N8N_MFA_ENABLED. Confirm each setting against your n8n version before rollout.

On this page

Enforcing 2FA in n8n for email and password logins

You can require two-factor authentication for every email and password login to a self-hosted n8n instance through the instance security settings. That matters because a self-hosted instance holds workflows, stored credentials and the connections those credentials open, and local email and password accounts are a common weak point. A password that is reused, phished or exposed in another breach can give an attacker the same access an administrator has. This control is for security leads, IT owners and platform engineers who run the instance and answer for who can reach it. It protects local accounts against stolen or reused passwords. It does not cover sign-ins that go through an identity provider over SAML, OIDC or LDAP, because those logins rely on the provider's own multi-factor controls and n8n does not see that second factor.

Before you enforce the setting, decide who holds local accounts at all. Many teams keep one or two break-glass owner accounts for recovery when the identity provider is down, and those accounts are exactly the ones that must have 2FA enrolled before enforcement starts, or the owner can lock themselves out. Plan how users will enroll, how recovery codes will be stored and who can reset a user's second factor when a phone is lost. Each of these steps depends on your version, so confirm the exact setting path, the enforcement behavior and the recovery flow in the n8n documentation for the release you run before you change production. Test the change on a non-production instance first, using a local account that mirrors your owner account.

Configuration options and when each fits

This table compares the instance-level enforcement setting, per-user 2FA enrollment, recovery codes and the N8N_MFA_ENABLED environment variable. Read each row for who controls the option, when it fits and what it costs you in flexibility or recovery risk.

OptionWhat it controls and who sets itWhen it fitsMain trade-off
Instance-level 2FA enforcementRequires every email and password user to enroll in 2FA. Set by an instance owner or admin in the n8n settings interface.Organizations that want one rule for all local accounts and a single place to audit it.Users who have not enrolled may be blocked until they do, so rollout needs a communication plan and a named support contact.
Per-user 2FA enrollmentLets an individual user turn on 2FA for their own account from their profile. Set by each user.Teams piloting 2FA, or users who want extra protection before enforcement is switched on.Nothing stops a user from skipping it, so this option alone does not give an assessor a control over every account.
Recovery codesOne-time backup codes issued during 2FA setup, used when the authenticator app is unavailable. Generated and stored by each user.Any instance with enforced 2FA, because a lost device otherwise locks a user out.Codes that are stored insecurely or never saved defeat the control. Confirm the regeneration and reset steps for your version.
N8N_MFA_ENABLED environment variableControls whether the 2FA feature is available on the instance at all. Set by whoever manages the server or container configuration.Environments where the 2FA feature must be turned off or kept unavailable, or where config is managed as code.Disabling it removes 2FA for the whole instance rather than tightening it. Confirm its default and supported values in the n8n docs for your version.
SSO-authenticated usersUsers who sign in through an identity provider are not governed by the local 2FA setting. Controlled by the identity provider's own MFA policy.Organizations that already enforce MFA centrally in their identity provider.Enforcing 2FA in n8n does not cover SSO logins, and local owner accounts may still need separate handling. Confirm the behavior with your SSO setup.

How 2FA treats each login path

Local accounts are the logins n8n checks itself. The instance stores the password and, when the setting is on, asks for a second factor after the password is accepted. This is the path the enforcement setting is designed to cover, so it is where your team should prove the control works from start to finish.

  • Who uses it: Owner, admin and member accounts created inside n8n, including any break-glass owner account kept for recovery.
  • Where the second factor is checked: In n8n, at login, after the password. The instance holds the enrollment and recovery material for each account.
  • Recovery material: Store recovery codes in your secrets vault, not in a shared document, and test the recovery path with a non-production account.
  • Instance-wide disable: Setting N8N_MFA_ENABLED to disable 2FA removes the prompt for every local account, so confirm its value in each environment.
  • Owner lockout: Decide in advance how the owner account is recovered if the authenticator device is lost.

Check this tab by creating a new local account, signing in from a clean browser and confirming the prompt appears before the workspace loads.

Setup sequence for enforcing 2FA

This sequence moves two-factor enforcement from a planned change to a verified production setting. Each step ends with a check, so the team knows whether to continue, correct the setup or roll back before any user is locked out of n8n.

  1. Confirm version, plan and login methods

    Record the running n8n version and check it against the n8n release notes. Confirm with n8n which plan your instance is on and whether the two-factor setting is available in that edition, since plan limits differ. Note how people sign in today, whether by email and password, SSO or LDAP, because the enforcement scope depends on it. Done when the version, plan and login methods are written down and a named owner has approved them.

  2. Back up the instance and encryption key

    Take a full backup of the n8n database and the instance configuration. Store the encryption key in your secrets vault, separate from the backup files, and record which environment settings the instance depends on. Restore the backup to a separate host and confirm that stored credentials decrypt with the recorded key. Done when a restore has succeeded, not just when the backup job reports success.

  3. Inventory local and SSO accounts

    List every user with their role, owner, admin or member, and their sign-in method. Mark accounts that authenticate through SSO or LDAP, since the identity provider handles their login, and confirm with your SSO configuration how those users are treated. Mark accounts that use email and password, because those are the logins the enforcement setting governs. Identify shared or service accounts and assign a human owner to each. Check: the inventory matches the instance user list and every account has a sign-in method and an owner.

  4. Enable enforcement on a test instance

    Restore the production backup to a test instance and turn on the two-factor enforcement setting in its security configuration. Leave production unchanged at this stage. Record the environment variable N8N_MFA_ENABLED, which disables two-factor authentication across the whole instance, and write down how your team would set it in an emergency. Check: sign in with an email and password account that has no second factor and confirm the login does not complete until a second factor is set up.

  5. Pilot group enrolls and saves recovery codes

    Choose a small pilot group with different roles, including at least one owner and one member. Ask each person to turn on two-factor authentication from their own profile and to save the recovery codes in your approved password manager or secure store. Without saved codes, a lost device can block access to the account. Check: each pilot user completes enrollment, confirms the recovery codes are stored, and reports any step in the flow that was unclear.

  6. Verify logins with and without a second factor

    Run a test matrix on the pilot accounts. Sign in with password and a valid code, with a recovery code, with a wrong code and with password only. Repeat the matrix for one SSO or LDAP account to confirm the behavior matches your inventory. Confirm with the n8n documentation for your version whether each recovery code is single use. Check: valid codes succeed, password-only and wrong-code attempts are refused, and any mismatch returns to the test instance before production.

  7. Confirm break-glass owner access

    Designate at least one owner account that can regain access if the primary administrators lose their devices. Record where its recovery codes are kept and who can reach them. Follow the recovery procedure in the n8n documentation for your version and test it on the test instance from a clean browser session. Check: the break-glass owner signs in and completes recovery without relying on another administrator, and two named people have the procedure written down.

  8. Roll out to production and watch sign-ins

    Apply the setting to production in an agreed change window, with the rollback steps and the break-glass owner available during the change. Tell users beforehand what enrollment looks like on their next sign-in. After the change, run the same login tests on production with a test account. Review failed sign-in attempts and support requests over the monitoring period your team agreed in advance. Done when the failed logins are the refusals the test matrix predicted.

How a login reaches the 2FA check

The login starts at the n8n sign-in page, where the instance first decides whether the account is a local email and password account or an SSO account. Local accounts pass the password check and then the 2FA check when enforcement is on. SSO accounts leave n8n for the identity provider, which applies its own MFA. A lost device goes to recovery codes or the owner recovery path. Confirm the exact sequence for your version before you rely on it.

Login decision path for local and SSO accounts, with the 2FA check and recovery route.

Security considerations before you enforce 2FA

Enforcing a second factor changes who can sign in, how they recover access and what evidence you can show later. The cards below cover the failure modes that most often catch teams off guard, and each one names the control to put in place and the point to confirm in your own instance before you switch the setting on.

Lockout of the only owner

If the sole owner account enrolls in 2FA and loses the device or recovery codes, nobody left in the instance can reset it from inside the application. Create a second owner account, enroll it in 2FA on a separate device and confirm that both accounts can sign in before you enforce the setting. Test the reset path on a staging instance first, since recovery depends on your own database and access to the server.

Recovery codes stored insecurely

Recovery codes bypass the second factor, so a copy saved in a shared document or chat channel is effectively a password. Give each user a written process for storing codes in a password manager they control, and confirm with the n8n user management docs where codes are displayed and whether they can be regenerated. Decide who handles lost-device requests and how that person verifies identity before resetting anything.

SSO users assumed covered

Teams often assume that turning on the 2FA setting also covers users who sign in through SAML or OIDC. Confirm in the n8n docs and in your own test login whether the setting applies to SSO sign-ins at all, and where your identity provider's MFA policy takes over. Document which login path each group of users uses so the control owner can explain the answer to an auditor.

Shared accounts without personal devices

A shared login used by a team or service cannot enroll a single personal authenticator without the device owner sharing a phone, which defeats the purpose of 2FA. Replace shared accounts with named users, or keep the shared account on a documented exception list with a named owner. Identify these accounts during the inventory before enforcement, because they will fail the first login after the change.

API access outside interactive login

Interactive 2FA protects the browser login, but automations that call the n8n API authenticate with API keys rather than a sign-in form. Confirm in the n8n API documentation whether keys are affected by the 2FA setting, and inventory which pipelines and integrations hold keys. Plan key scope, expiry and rotation as a separate control, because an enforced login policy will not protect a leaked key on its own.

Audit evidence of second factor use

An auditor may ask for proof that each login used a second factor, not only that the setting was switched on. Confirm which login events your n8n version records, whether the second factor step appears in those records, and where logs go after they leave the instance. Set a test that signs in with a new user, then check that your log pipeline captures the event before you rely on it as evidence.

Recovery codes and avoiding an owner lockout

Recovery codes are the fallback when a user cannot reach their authenticator app, so the plan for enforcing 2FA starts with them. In the standard setup flow, each user enables 2FA on their own account and is shown a set of recovery codes, usually once. Confirm in your version whether codes are displayed only at setup, how many are issued, whether users can regenerate them, and whether a used code is consumed. Treat every code as a credential: store it in your organization's password manager or secrets vault, never in a shared document, chat thread or ticket. A leaked code lets someone pass the second factor for that account, so it deserves the same handling as the password itself.

The lockout risk appears when enforcement is on and the only owner loses their device without a usable recovery code. Every account, the owner's included, must then pass the 2FA step, so nobody can sign in through the interface to change settings or reset access for others. Recovery then depends on steps you must confirm with n8n's documentation for your version: whether an administrator can reset another user's 2FA from the interface, and if not, what the supported fallback is. Do not assume a direct database change is safe or supported until someone on your team has checked it against a test instance.

Plan the recovery path before you turn enforcement on. Keep at least two owner or administrator accounts, each enrolled in 2FA, with their recovery codes stored in separate vault entries that more than one trusted person can reach. Test the path on a non-production instance: enroll an account, lose the device in your mind, sign in with a recovery code, and confirm that an administrator can reset a different account if your version supports it. Write the steps down with named owners and the location of the codes, and keep a tested break-glass route for the case where every administrator is locked out. Enforce only after that test passes.

Limits to confirm in your environment

The 2FA enforcement setting only protects you if it reaches every login path in your deployment. The questions below cover account types, deployment method, queue mode, existing sessions and the documented behavior of your release, and each should be answered in a test instance before enforcement reaches production users.

Coverage of local accounts

Confirm whether enforcement applies to every local email and password account, including the instance owner created during first setup. Test with a fresh owner account, a member account and an admin account, and check that each is prompted for a second factor at login. Record any account that can sign in with a password alone, since a single unenforced account can undermine the policy for the whole instance.

Interaction with SSO and LDAP

Confirm how enforcement treats users who sign in through SAML, OIDC or LDAP, and whether your plan includes those methods at all. Identity provider policy usually governs second factors for these users, so the n8n setting may not add a check. Confirm in writing which layer owns MFA for each login path and who maintains it, and keep a local owner account for recovery only if your policy allows it.

Honoring N8N_MFA_ENABLED by deployment method

Confirm that the N8N_MFA_ENABLED variable is read from the environment in your deployment method, whether Docker, Kubernetes or Compose. Check that the value reaches the running container, for example by inspecting the process environment, and that a restart or rollout picks it up. Also confirm whether a secret or config map overrides it, since a stale value can silently re-enable or disable the feature.

Behavior in queue mode

Confirm how the setting behaves when several main instances or workers share one PostgreSQL database and Redis queue. Each instance that serves the editor and login must enforce the same policy, so verify that all main instances carry the same variable and that webhook processors do not need it to protect the editor. Test a login against each instance behind your load balancer before you declare the policy active.

Queue mode docs

Existing sessions and enrolled users

Confirm what happens to sessions that are already open when enforcement is turned on or off, and whether users who have not yet enrolled are blocked at their next login or on the next page load. Also confirm how recovery codes issued before a change behave afterward. Plan a notice to users and a window to enroll, and test a session that was opened before the change.

Support in your release

Confirm in the n8n documentation for the exact release you run that the setting exists, its default value, and whether it is listed as supported or only as an internal option. Release notes change between versions, so record the version you tested and retest after every upgrade. Ask your vendor or support contact to confirm any behavior the docs do not describe.

n8n release notes

Questions buyers ask about 2FA enforcement in n8n

What does enforcing 2FA in n8n cost, and what drives the effort?

The cost is the engineering time to change the setting, test it, document the result and complete any change control your organization requires. DeployOpen quotes follow from a written scope, so the figure depends on the factors below. The main drivers are instance size and the number of local email and password accounts, because each one needs an enrollment path and a recovery plan. The share of users who sign in through SSO also matters, since those users are handled differently and need a decision about where second-factor checks happen. Formal approvals, maintenance windows and evidence requirements add effort. Ask for a quote that itemizes discovery, configuration, testing, rollout support and documentation separately.

How long does a 2FA rollout take in n8n?

The duration depends on how many people sign in with local accounts, how much notice they receive and how quickly they can enroll. The configuration change is small, but the rollout is driven by people. Users must set up an authenticator app and store their recovery codes before they lose access, so switching the setting on a live instance without preparation creates support requests. Plan for a pilot group, a communication period and a support window in which administrators can help locked-out users. If your organization requires formal change approval, add time for the request, testing in a non-production instance and sign-off. Confirm each step's duration with your own team, because no fixed timeline applies to every organization.

What does the client need to provide for this work?

You need owner-level access to the n8n instance and administrative access to the identity provider if SSO is in use. Access to the host or container platform, the environment configuration and the current backup status should also be available, so the change can be tested and reverted. A pilot group of real users is needed to check enrollment before the policy applies to everyone. A change window matters because enforcing login rules affects every user at once. Name one contact who can approve the change and a second person who can recover locked-out accounts. Agree these items in the written scope before work starts so nothing is missing on the day of the change.

Can our internal team enforce 2FA in n8n without a partner?

Yes, a team that already administers n8n can usually change the setting, test it and write a runbook without outside help. The question is mostly about capacity and coverage. The steps that tend to be missed are the operational ones: recovery for locked-out users, how SSO and local accounts behave during the transition and a test that confirms the policy still holds after an upgrade. Check whether someone on your team can run the rollout during business hours and handle support requests for several days afterward. If one of those gaps exists, the internal team can still do the work with targeted outside help on the parts it cannot cover.

When does an outside partner add value to 2FA enforcement?

A partner adds value when the rollout touches several systems at once, when evidence is needed for a compliance review or when the internal team lacks time. DeployOpen plans, implements, hardens, documents and supports self-hosted platforms inside your own infrastructure. It also prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications, which remain the job of an independent auditor. In a fixed-scope engagement, the partner documents the configuration, tests each login path, prepares a rollback plan and hands over a runbook. Ongoing support, upgrades and continuous testing are available as retainers.

Is disabling 2FA with N8N_MFA_ENABLED a safe fallback?

Treat N8N_MFA_ENABLED as a temporary recovery step only, and plan the enforced state as the end point. Setting it to disable 2FA across the whole instance removes the second factor for every email and password login, so any use should be recorded in a change ticket, time-limited and reversed once the affected users can sign in again. Confirm how the variable behaves in the version you run, and test it in a non-production instance before you depend on it. For a single locked-out user, recovery codes or an administrator who can reset enrollment are usually the first option to try, because they keep the protection in place for everyone else.

How does 2FA enforcement interact with SSO sign-in in n8n?

Users who sign in through SSO authenticate at the identity provider, so the second factor for those users is usually handled there, while the email and password 2FA setting governs local accounts. Confirm this behavior for your version and configuration, because the treatment of SSO users is the part of the setting most likely to surprise a rollout. Test one SSO user and one local user in staging before enforcing. Keep a local owner account available for break-glass access, and check whether your identity provider already enforces its own multi-factor policy. SSO is included only in the Business and Enterprise plans, so confirm your plan before you design around it: n8n pricing.

How DeployOpen works on this

DeployOpen plans and delivers two-factor enforcement for your n8n instance inside your own infrastructure, starting from your login paths, your admin accounts and your recovery process. Each step is agreed in writing so your security and identity teams can review the setting, the recovery procedure and the evidence before it reaches users.

How we scope

  • Inventory which users sign in with email and password and which sign in through SSO or LDAP
  • Agree the written scope, deliverables and timeline before any change is made to the instance
  • Confirm which owner and admin accounts must keep a recovery path if a 2FA device is lost
  • Record the N8N_MFA_ENABLED decision and who may approve disabling 2FA instance-wide

How we build

  • Enable the enforcement setting on a test instance that mirrors your production configuration
  • Test enrollment, login, recovery code use and admin reset with named test accounts
  • Check how SSO users are handled so no login path is left unreviewed or accidentally blocked
  • Document each configuration key and the exact UI steps your administrators will repeat

How we hand over

  • Deliver a written runbook covering enrollment, lockout recovery and recovery code storage
  • Provide evidence of test results that your security and compliance teams can review
  • Walk administrators through the rollout plan, communication to users and the rollback steps
  • Hand over a list of open questions to confirm with your identity provider and internal policy owners

How we support

  • Retest the 2FA setting after n8n upgrades, since login behavior can change between releases
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Review access logs and lockout requests on a schedule agreed in the retainer scope
  • Update the runbook when your identity provider, login paths or policies change

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.