Managing the Open WebUI secret key

Set WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY before first use, store them outside the container image, and plan rotation around sessions, MFA enrollments and installed apps.

On this page

Why the Open WebUI secret key matters before the first login

Set WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY deliberately before anyone signs in to a new Open WebUI instance. The first key is used to sign and protect the session credentials that keep users signed in, and the second protects the secrets that store each user's authenticator-app MFA setup. Choosing both values once, storing them outside the container image, and recording where they live is far cheaper than discovering later that a change signs everyone out or locks people out of their second factor.

How long a session lasts and what sign-out actually does depend on your deployment, not only on the key. The Open WebUI scaling guidance notes that without Redis, signing out does not revoke tokens; they stay valid until they expire, by default after 4 weeks. Confirm your session behavior in your own environment before you promise users or auditors that sign-out ends access, and check whether your replicas share the state needed to honor it. Plan for that lifetime when you decide how quickly a compromised session must stop working.

The MFA key matters because Open WebUI supports authenticator-app MFA, documented in its features reference, and that feature depends on the stored enrollment secrets being readable after a restart. This page covers how to set both keys, where to store them, what breaks when a key changes, and how to rotate them safely. Read the features documentation and the scaling guide before you start, and confirm with your own test instance which components your chosen install method uses.

Which key settings to configure and when each fits

This table compares WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY against the three places you can keep them: a file, an environment variable and an external secret manager. Read each row against your deployment shape, then check the exact variable behavior in the Open WebUI documentation for the version you run. The main takeaway is that the MFA key should be decided before any user enrolls in MFA, because it is the setting you will need to rotate later.

Setting and storage optionWhen it fitsMain trade-offWhat to confirm
WEBUI_SECRET_KEY as an environment variableSingle container or a small Compose stack where one host manages the container definitionEasy to set, but the value can appear in container inspection output, shell history and process listings if handled carelesslyHow your installed version reads the variable and whether it is required at first start
WEBUI_SECRET_KEY in a mounted fileCompose or VM deployments where the file can be owned by the container user and kept out of version controlFile permissions and host backups become the control point; a copied backup carries the keyWhether your version supports a file-based variant and which path it expects
WEBUI_SECRET_KEY from an external secret managerKubernetes with a secret store, or multi-replica deployments that must share one value across every podAdds a dependency on the secret store for startup and needs a sync or injection pattern you maintainHow your secret store injects the value and who can read it
MFA_ENCRYPTION_KEY set before enrollmentAny deployment that will enable authenticator-app MFA, including pilotsSet it at the start, because changing it later affects stored MFA secrets and requires a planned re-enrollment or migrationWhether the variable is separate from WEBUI_SECRET_KEY in your version and its exact format
MFA_ENCRYPTION_KEY stored with the same method as WEBUI_SECRET_KEYTeams that want one storage pattern for all Open WebUI keysSimpler operations, but a single store compromise exposes both keys; separate access rights where the store allows itWhether your secret manager can grant different read rights per key
Multi-replica deployments sharing one keySeveral replicas behind a load balancer that must accept the same sessions and encrypted dataEvery replica must read the identical value, so a per-pod generated key will cause failuresThat all replicas start with the same value and that Redis and shared storage are in place
Key backup and recoveryEvery production deployment, stored apart from the running systemWithout a copy, a lost key can prevent decryption of data; with a copy, the backup is itself sensitiveWhere the approved copy lives and who can restore it under change control

Secrets enter at startup, while sessions and MFA data sit in shared stores

The diagram starts at the secret store or environment, which sits outside the trust boundary around the running container. Each Open WebUI replica receives its configuration from that side, so every replica needs a consistent value. Session state for multi-replica setups lives in the shared Redis store, while user and MFA records live in the database and uploads sit in shared file storage. Check how each replica receives the value, confirm that no copy is baked into the image, and confirm which data each store holds before you plan a rotation.

Secret flow from the store into replicas, and the shared stores they use.

Setting WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY before first login

This sequence gives you two distinct, separately stored keys, loaded into Open WebUI at runtime before any user enrolls in authenticator-app MFA. The result is a deployment where sessions survive restarts and MFA secrets are protected by a key you can later rotate deliberately.

  1. Generate two distinct high-entropy keys

    The platform engineer generates two independent random values from a cryptographically secure generator on a trusted workstation, one for WEBUI_SECRET_KEY and one for MFA_ENCRYPTION_KEY. Use a generator your security team approves, such as the operating system's random source, and avoid passwords, dictionary words or values derived from hostnames. Confirm the two values differ from each other and that each is long enough for your team's standard. The check is a side-by-side comparison showing the values are not equal and were produced in a single session that you can document.

  2. Store both values in the approved secret store

    The platform engineer writes each value into the organization's approved secret store, such as a vault, cloud secrets manager or sealed Kubernetes secret, under separate names that match the variable names. Restrict read access to the service account that runs Open WebUI and to a small named group of administrators. The check is a listing from the secret store that shows both entries exist, with distinct names, and an access policy that limits who can read them.

  3. Inject both values at runtime, not in files

    The platform engineer configures the deployment to read both variables from the secret store at container start, through the orchestrator's secret mechanism or an environment file generated outside version control. Confirm that the Dockerfile, image layers, Compose files and Helm values committed to the repository contain only references to the secret names, never the values. The check is a search of the repository and image history for the key strings, which should return no matches, and a review of the rendered deployment that shows the variables as secret references.

  4. Set MFA_ENCRYPTION_KEY before enabling MFA

    Before any user is allowed to enroll an authenticator app, the platform engineer confirms that MFA_ENCRYPTION_KEY is loaded and that the administrator team has agreed to keep MFA disabled for all accounts until this step is complete. This ordering matters because MFA secrets are encrypted with that key, and changing it later affects enrolled users. Confirm with your Open WebUI version's documentation how MFA is switched on in your environment. The check is a written sign-off from the administrator that enrollment is still closed.

  5. Restart and confirm both values are loaded

    The platform engineer restarts the Open WebUI container or pod so that it reads the injected values, then inspects the running process environment to confirm both variable names are set and non-empty, without printing the values to the console or logs. Check the startup log for any warning about a missing or default key. The check is a presence test for both variables inside the running workload and a clean startup log with no key-related errors.

  6. Verify sessions survive a container restart

    The administrator signs in with a test account, confirms the session works, then the platform engineer restarts the container once more and checks that the same session still authenticates without a fresh sign-in. If sessions drop, the cause is usually a secret that changed between restarts or a value injected from a different source, so compare the secret store entry before retrying. Also confirm that a test account with MFA enrollment, if you enable it in a pilot, can still sign in after the restart. The check is a successful session reuse after restart, recorded in the test notes.

  7. Record identifiers and setup date in the runbook

    The platform engineer adds an entry to the operations runbook that lists the secret names, the secret store location, the setup date, the person who performed setup and the deployment version. Do not record the key values, partial values, hashes or any fragment that could help reconstruct them. Set a review point so the next change to either key goes through the same written process. The check is a runbook entry that a second administrator can read and use to locate the keys without seeing them.

What rotation breaks in sessions, MFA and installed apps

Sessions are the most visible part of a rotation. Open WebUI uses the secret key as part of how it protects the session state it issues, so changing the key is expected to end existing sign-ins and force users to authenticate again. Confirm exactly which tokens and cookies are affected in the Open WebUI docs and in a staging rebuild, because the supplied material does not describe the behavior of each key in detail.

  • Expected effect: users are likely signed out and must sign in again after the new key takes effect.
  • Token lifetime: without Redis, sign-out does not revoke tokens, and they remain valid until expiry, by default 4 weeks. Confirm how a rotation interacts with that lifetime.
  • Multi-replica timing: all replicas should receive the same key at the same time. Confirm this behavior before relying on a rolling restart.
  • Testing: sign in with SSO and local accounts on staging after the change, and confirm API keys still work where you expect them to.
  • Communication: tell users the sign-in prompt is expected, and schedule the change outside peak working hours.

Before the change, record which sign-in methods your users rely on so you can check each one afterward.

Storing the keys without leaking them into images, logs or backups

WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY protect sessions and stored MFA secrets, so a copy of either value is a copy of something an attacker can use. The risks below cover the places keys most often end up: build artifacts, version control, logs, backups and shared environments. Check each one against your own deployment before go-live.

Keys baked into images

A key set in a Dockerfile, an ENV line or a build argument stays in the image layers and in every registry copy of that image. Inject the value at runtime from your secret manager or orchestrator instead. Verify by inspecting the image history and searching the layers for the key value, then confirming the running container gets its value from the runtime environment.

Open WebUI features docs

Keys in compose files or Helm values

Compose files and Helm values committed to git turn the key into part of the repository history, where deleting the file later does not remove it. Reference a secret object or an external secret store from these files rather than the literal value. Verify with a repository secret scan and by confirming the key is absent from the rendered manifests kept in version control.

Keys printed in startup or debug logs

Startup scripts, wrapper scripts and debug output can echo environment variables into container logs, which then flow to log shippers and support tickets. Review how your launch script handles variables and confirm that log pipelines redact or drop these names. Verify by starting the service at a debug level and searching the captured output for the key value.

Keys copied into backups unencrypted

Volume snapshots and backups of the data directory or environment files can carry the key in clear text, and a restore then exposes it to anyone with backup access. Decide where the key lives outside the data volume, encrypt backup storage, and restrict who can restore. Verify by restoring a backup into an isolated environment and checking which copies of the key the restored system holds.

Shared keys across dev and production

Reusing one key in development, staging and production lets a leaked test value forge sessions in production and makes test data interchangeable with live data. Generate a separate value for each environment and record which key belongs to which instance. Verify by confirming that a session token issued by one environment is rejected by the others.

Administrators who do not need the keys

Anyone who can read the container environment, the orchestrator secret objects or the host filesystem can read the key, whether or not they run the application. Limit read access to the secret store to the deployment pipeline and a small named group, and log every read. Verify by listing who holds read permission on each secret store and comparing that list with your approved operators.

What to confirm before you rotate the key in production

Before you rotate WEBUI_SECRET_KEY in production, build a staging copy of the deployment that uses the same image version, the same database and the same identity provider settings, then rotate the key there first. Confirm with the Open WebUI documentation and your own tests exactly which artifacts depend on the current value: user sessions, MFA enrollments, API keys, and any installed apps or integrations that sign or encrypt data with it. Record each dependency in writing, because the answer determines whether users must sign in again, re-enroll authenticator apps, or reconfigure integrations after the change.

Next, agree a maintenance window with the business owners and tell them which user groups will be affected. Produce a current list of users with MFA enrolled, and export it from the database or admin interface so you can confirm afterward who must re-enroll. Check that MFA_ENCRYPTION_KEY is already set and stored separately, since that is the step that makes a later rotation of the main key less disruptive. Ask your team to confirm who is authorized to approve the change and who will answer user questions during the window.

Finally, plan the rollback path before you touch production. Keep the previous key value in your secrets store, labeled with the date and deployment it belongs to, and do not delete it until verification passes. Write test cases for sign-in, MFA challenge, API key use, and one installed app or integration, and run them in staging and again in production. Confirm with your own environment how a restart with the old key behaves, and rehearse that restart once in staging so the rollback is a known procedure rather than an untested guess.

Questions teams ask before changing the Open WebUI secret key

Can our own team set and rotate the Open WebUI secret key without a partner?

Yes, if your team can change the environment variable in every running instance, restart them in a controlled order, and keep the key out of logs and images. The hard part is not the change itself but the planning around it: you need to know which sessions, MFA enrollments and installed apps depend on the current key before you touch it. Teams with a secret store, a staging copy of the deployment and a documented change window usually handle this in-house. Teams without those usually ask for a fixed-scope engagement so the procedure is written, tested and handed over.

What does our team need to provide for a key change?

Three things matter most: access to the secret store that holds WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY, a staging environment that mirrors production closely enough to rehearse a rotation, and a change control process that names an owner, a window and a rollback step. You also need a list of every replica, worker and tool server that reads the key. Confirm these with your security team early, because access approvals are often the longest step in practice. A quote from DeployOpen follows from the scope you write down, so listing these items up front makes that quote more accurate.

How long do setup and a rotation take?

Duration depends on your environment, so the honest answer is that it varies with the number of instances, the state your deployment holds and how many approvals the change needs. Setting MFA_ENCRYPTION_KEY before any MFA enrollment is quick when the deployment is new and takes longer when many users already have authenticator apps enrolled. A rotation in a single-instance deployment with a rehearsed plan is usually a short change window, while multi-replica setups need coordinated restarts. Ask any partner, including DeployOpen, to state the duration in the written scope rather than relying on a general figure.

What makes the effort go up?

Four drivers matter most. The number of replicas multiplies the restarts and the places the new key must reach. The number of users with MFA enrolled determines how many TOTP secrets must be re-encrypted or re-enrolled, depending on how your key was set. Integrations, such as connected model servers, tool servers and installed apps, may store or depend on values derived from the key and need retesting. Finally, the size of your change control process affects how many reviews and approvals the work requires. Each driver changes the quote, so describe them in detail when you ask for one.

What recurs after the first key change?

Once the key is set, the recurring work is governance rather than daily operation. Most organizations schedule periodic rotation under their key management policy, and each rotation repeats the planning, staging rehearsal and change window. Key custody reviews also recur: someone must confirm who can read the secret store, that backups do not expose the key in plain text, and that old keys are retired. These tasks are usually owned by the platform or security team. A DeployOpen retainer can cover recurring support, but the schedule and scope are agreed in writing.

Does a Redis-backed deployment change sign-out behavior?

Yes, and this matters for rotation planning. Open WebUI's scaling guide says that without Redis, signing out does not revoke tokens, which then stay valid until they expire, by default after 4 weeks. A Redis-backed deployment shares session and application state across replicas, so sign-out and session handling behave consistently across instances. When you rotate the secret key, plan for active sessions to end or fail validation, and tell users to sign in again. Confirm the exact behavior of your version in the release notes before the change window, since the project publishes new releases regularly.

When should we ask DeployOpen for a fixed-scope engagement?

Ask for a fixed-scope engagement when the key change touches several replicas, a large MFA population, connected integrations or a regulated audit trail, or when your team lacks a rehearsal environment. DeployOpen agrees scope, deliverables and timelines in writing before work starts, so you know what is covered and what you own afterward. Send a short description of your topology, your current MFA state, your integrations and your change control requirements. The written scope and quote then follow from that description, and DeployOpen does not publish a price list.

How DeployOpen works on this

DeployOpen treats Managing the Open WebUI secret key as a planned change to a running deployment, not a one-time setting. We scope the key handling, set MFA_ENCRYPTION_KEY before any rotation is needed, build the storage and rotation runbook inside your infrastructure, and hand over documented evidence your security team can review.

How we scope

  • Inventory where WEBUI_SECRET_KEY and MFA_ENCRYPTION_KEY are set today, including compose files, Helm values and container environments
  • Agree in writing which secret store, access roles and rotation owner apply to your Open WebUI instances
  • Confirm which sessions, MFA enrollments and installed apps your users depend on before any rotation is scheduled
  • Define the fixed-scope deliverables, timeline and acceptance checks before the work starts

How we build

  • Set MFA_ENCRYPTION_KEY first, so authenticator secrets can be re-encrypted later without re-enrolling users
  • Load WEBUI_SECRET_KEY from your secret manager rather than from plain environment files in version control
  • Build and test a rotation runbook in a non-production copy, recording which user-facing items break at each step
  • Verify that every replica and worker receives the same key values before a rolling restart is accepted

How we hand over

  • Deliver a written key inventory, storage design and access list for the Open WebUI deployment
  • Provide a tested rotation runbook with rollback steps, owners and a communication template for affected users
  • Document the evidence your compliance team can use for key management controls, without us issuing any audit opinion
  • Walk your operations team through the runbook and record their questions and sign-off

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover
  • A retainer can cover scheduled rotations, review of key handling after Open WebUI upgrades and reruns of the rotation test
  • Ask any provider which key rotation steps they will repeat after each release, and who approves them
  • Confirm response expectations and support hours in the written scope before signing

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.