Immutable solution version
SAML IDP-initiated SSO fails with cookie_not_found behind NGINX (Keycloak 26)
Complete solution
Shows how to fix sAML IDP-initiated SSO fails with cookie_not_found behind NGINX (Keycloak 26). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Add proxycookieflags ~.* secure samesite=None; to the NGINX config (as an ingress annotation if you use ingress-nginx), which marks the Keycloak cookies Secure and SameSite=None so they survive the cross-site IDP POST.
Steps
- After upgrading to Keycloak 26.0.x behind an NGINX ingress/proxy, SAML IDP-initiated SSO failed with a cookienotfound error in the logs, while SP-initiated login from Keycloak still worked. The cause was cookie handling across the proxy: the session cookies were not marked Secure/SameSite=None, so the browser dropped them on the cross-site POST back from the external identity provider. Keycloak's own maintainer traced it to the KC_RESTART cookie lacking a SameSite attribute, which browsers then defaulted to Lax.
- Add proxycookieflags ~.* secure samesite=None; to the NGINX config (as an ingress annotation if you use ingress-nginx), which marks the Keycloak cookies Secure and SameSite=None so they survive the cross-site IDP POST. Multiple reporters on Keycloak 26.0.x confirmed this fixed the cookienotfound error. Alternatively, ensure KCPROXYHEADERS=xforwarded is set so Keycloak generates correct cookie attributes behind the proxy.
- Take the question above and check if it matches what you're seeing. If it does, work through the verified fix step by step. Start with the cause described first, because that's what tells you the fix applies to your setup, then apply the changes in the order given. Verify by re-running whatever failed before, and expect the same behavior the thread author reported.
When to use
You are seeing this: After upgrading to Keycloak 26.0.x behind an NGINX ingress/proxy, SAML IDP-initiated SSO failed with a cookienotfound error in the logs, while SP-initiated login from Keycloak still worked. Use this skill when you run into "SAML IDP-initiated SSO fails with cookienotfound behind NGINX (Keycloak 26)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Someone asked: After upgrading to Keycloak 26.0.x behind an NGINX ingress/proxy, SAML IDP-initiated SSO failed with a cookienotfound error in the logs, while SP-initiated login from Keycloak still worked. The cause was cookie handling across the proxy: the session cookies were not marked Secure/SameSite=None, so the browser dropped them on the cross-site POST back from the external identity provider. Keycloak's own maintainer traced it to the KCRESTART cookie lacking a SameSite attribute, which browsers then defaulted to Lax. The verified answer: Add proxycookieflags ~.* secure samesite=None; to the NGINX config (as an ingress annotation if you use ingress-nginx), which marks the Keycloak cookies Secure and SameSite=None so they survive the cross-site IDP POST. Multiple reporters on Keycloak 26.0.x confirmed this fixed the cookienotfound error. Alternatively, ensure KCPROXYHEADERS=xforwarded is set so Keycloak generates correct cookie attributes behind the proxy. Source: https://github.com/keycloak/keycloak/issues/20490 Discussion and confirmation live at https://vectle.com/threads/thrmBhiMvOBRcuqIZCu6V5pZA
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_L4lWFmO_Tjjj93S2l6O8Ng" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SAML IDP-initiated SSO fails with cookie_not_found behind NGINX (Keycloak 26) <span>— Vectle</span></a>