Open WebUI SSO: "mismatching_state: CSRF Warning! State not equal in request and response"

Update, 9 November 2026: Open WebUI 0.13.1 (8 November 2026) fixes the case in issue #33783, where automatic SSO redirect fails after a sign-in session expires. Its release notes say: "With automatic SSO redirect on, an expired session now signs you back in without a state mismatch error." If that is what you see, update to 0.13.3, the newest release (8 November 2026); the Open WebUI advisory page lists what to check before you upgrade.

Of the Open WebUI source files the causes below were checked against, main.py and utils/oauth.py changed between 0.13.0 and 0.13.3 (env.py and start.sh did not). The causes below were reproduced with 0.13.0 and have not been re-run with 0.13.3 yet. Checked with AI agents working for MV2 of Munim, Inc.

By MV2 of Munim, Inc., with AI agents. Checked on 7 November 2026 against the source of Open WebUI 0.13.0, the newest release then. Every cause below was run with the libraries that release pins (Authlib 1.7.2, FastAPI 0.136.3, Starlette 1.10.0) and Open WebUI's own session settings, against a small local identity provider, not a full Open WebUI install.

After you sign in at your identity provider (Keycloak, Authentik, Entra ID, Google, and so on), Open WebUI sends you back to its sign-in page with this message:

Sign-in with your identity provider failed. Please contact your administrator for assistance.

The reason is in the server log (docker logs open-webui), in a warning like this:

OAuth callback error during authorize_access_token for provider oidc: OAuth callback failed: mismatching_state: CSRF Warning! State not equal in request and response.

Short answer: the redirect back from the provider arrived without the browser session that started the sign-in, or with a session that no longer holds that sign-in. When you click the SSO button, Open WebUI stores a one-time state in its owui-session cookie, signed with WEBUI_SECRET_KEY (or in Redis, if ENABLE_STAR_SESSIONS_MIDDLEWARE=true and REDIS_URL are set). When the provider sends you back, Authlib compares the state in the URL with the one in that session. If the cookie is missing, was signed with another key, or no longer holds that state, you get this error. Open WebUI's issue #33783 (opened 5 November 2026) describes one way this happens with automatic SSO redirect after a sign-in token expires; it was closed as completed on 6 November 2026, after Open WebUI 0.13.0 was released, so look for the fix in a later release.

Open WebUI's own SSO troubleshooting page lists this error too. This page adds a run of each cause, so you can tell them apart.

The causes, each one run

CauseWhat we ranResultFix
Two or more Open WebUI containers or replicas with different secret keysSign-in started on instance A; the redirect back from the provider landed on instance B, whose WEBUI_SECRET_KEY is different.mismatching_stateGive every replica the same WEBUI_SECRET_KEY (below).
The same two replicas with the same secret keySame as above, but both instances share one WEBUI_SECRET_KEY.signed inNothing to fix: with the default cookie sessions, the cookie carries the state, so any replica with the same key can finish the sign-in.
OPENID_REDIRECT_URI points at a different address than the one in the browserOpened Open WebUI at one host; OPENID_REDIRECT_URI named another (for example the IP address versus the domain name). (Browser step simulated: no cookie sent, as a browser would.)mismatching_stateOpen Open WebUI at exactly the scheme, host and port in OPENID_REDIRECT_URI, or redirect users there.
WEBUI_SESSION_COOKIE_SAME_SITE=strictThe session cookie was set with SameSite=strict. (Browser step simulated: no cookie sent, as a browser would.)mismatching_stateUse lax, the default. WEBUI_AUTH_COOKIE_SAME_SITE sets the sign-in token cookie separately.
WEBUI_SESSION_COOKIE_SECURE=true while Open WebUI is served over plain http://The session cookie was marked Secure on an http address. (Browser step simulated: no cookie sent, as a browser would.)mismatching_stateServe Open WebUI over https (for example behind a reverse proxy), or leave it false while you use plain http.
Sign-in was started twice before the first one finished (a second tab, or the SSO button clicked again)Started sign-in twice with one cookie, then finished the first one, then the second.first: mismatching_state; second: signed inFinish the sign-in you started last, or close the other tabs and start once. Authlib 1.7.2 keeps only the newest sign-in state per provider in the session (its Starlette integration removes older ones "to avoid session size growing"), so an earlier tab's sign-in can no longer finish.
The session was cleared between the click and the callbackSigned out in between: the sign-out response deletes the owui-session cookie.mismatching_stateSign in again. If it happens with automatic SSO redirect, see Open WebUI issue #33783.
The callback page was loaded twice (reload, back button, or a bookmarked callback URL)Signed in, then loaded the same callback URL again.mismatching_stateHarmless: the first load signed in. Start sign-in from the login page instead of reloading the callback.

In every mismatching_state row, Authlib raised mismatching_state: CSRF Warning! State not equal in request and response. at the callback; Open WebUI logs that and redirects to /auth?error=… with the message above.

Which one is it? Look at the callback request

  1. Open the browser's developer tools (F12), Network tab, and tick "Preserve log".
  2. Click the SSO button and sign in at the provider.
  3. Find the request to /oauth/<provider>/login/callback (or the older /oauth/<provider>/callback) and look at its request headers.

Set one WEBUI_SECRET_KEY for every container

If you never set WEBUI_SECRET_KEY, Open WebUI's start.sh generates one into /app/backend/.webui_secret_key inside the container. The docker run commands in Open WebUI's README mount the volume at -v open-webui:/app/backend/data, so that file is not in it: each replica, and each new container (for example after docker pull and re-create), makes its own key. Check whether yours is set:

docker exec open-webui sh -c 'if [ -n "$WEBUI_SECRET_KEY" ]; then echo set; else echo "not set: generated in /app/backend/.webui_secret_key"; fi'

Generate one value once (openssl rand -hex 32), keep it with your other secrets, and pass the same value to every container, for example -e WEBUI_SECRET_KEY=… in docker run or under environment: in Docker Compose.

Check the rest of your setup

The free local-ai-checkup script shows which AI ports on your machine other computers can reach, and the CVE checker tells you which security advisories affect your Open WebUI version. Both are read-only and send nothing off the machine.

Want someone to check it for you?

MV2 of Munim, Inc. does a $49 local AI health check for one machine, or a $199 small-office check for up to 5 machines or one shared Ollama or Open WebUI server. You get a written report of what's exposed, risky or slow and what to fix first, with exact commands for your OS. See a sample report. Pay $49 or pay $199 on Stripe, then email mv2@munimtech.com the output of python3 local_ai_checkup.py --json, your OS, and what you use it for. MV2 never asks for passwords, keys or remote access.