Keycloak: Invalid parameter: redirect_uri
Keycloak rejected the redirect URI because it is not listed in the client's Valid Redirect URIs, or a wildcard pattern does not cover it.
Quick fix
Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.
# Keycloak Admin -> Clients -> your-client -> Settings
# Valid Redirect URIs (supports a trailing * wildcard):
https://app.example.com/*
http://localhost:3000/*
# Web origins (CORS): + (to allow all valid redirect origins)
How to diagnose Auth errors
Identity errors are almost always configuration mismatches between two systems rather than code bugs: a redirect URI registered with a trailing slash, a client secret that was rotated on one side only, a clock that has drifted past the token skew allowance. Because the identity provider deliberately returns vague errors to avoid leaking information to attackers, the provider's own log is usually far more informative than the message your application receives.
If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.
- Open the identity provider's log or event stream first. Auth0, Okta and Keycloak all record a detailed reason that they never send back to the client.
- Compare the redirect URI byte for byte, including scheme, port and trailing slash.
http://localhost:3000/callbackandhttp://localhost:3000/callback/are different URIs. - Decode the token rather than guessing. Paste it into a local JWT decoder and check
iss,aud,expandnbf, never a remote paste site, because tokens are credentials. - Check clock skew with
timedatectlorntpq -p. Kerberos, SAML and JWT all reject tokens outside a tight time window, and a drifting VM clock produces intermittent, unreproducible auth failures. - For passkeys and WebAuthn, verify the Relying Party ID matches the origin exactly and that the page is served over HTTPS or on
localhost. Nothing else is a secure context.
Tools worth reaching for
Provider audit logsjwt decoding (locally)openssl x509 -noout -textbrowser devtools network tab
Authoritative references
Primary documentation for this error, worth reading before applying any fix in production.
Related Auth errors
- Auth0: Callback URL mismatchAuth0 rejected the login because the redirect URL in the request is not in the application's…
- Google OAuth: Error 403: access_denied, app is in testingThe OAuth consent screen is in Testing mode, which only allows the accounts explicitly listed…
- JWT: token used before issued / not valid yetValidation compared the token's iat or nbf claim against the verifier's clock and decided the…
- MFA: challenge timeout / code expiredA TOTP or push challenge was rejected because it expired or the device clock drifted outside…
- Microsoft Entra ID: AADSTS50011 (redirect URI mismatch)The redirect_uri sent in the authorisation request is not registered on the app registration…
- OAuth 2: invalid_grant (PKCE code_verifier does not match)The code_verifier sent to the token endpoint does not hash to the code_challenge sent to the…
- OIDC: nonce mismatchThe nonce in the returned ID token does not match the nonce sent in the auth request…
- OIDC: unable to find a signing key that matches the kidThe token was signed with a key the verifier does not have. Identity providers rotate signing…
Browse other categories
- HTTP 494xx client errors, 5xx server errors, redirects, headers and protocol problems.
- JavaScript 42npm resolution, async pitfalls, hydration, memory limits and runtime type…
- Database 41Connections, deadlocks, constraints, replication and memory limits.
- AI 35Rate limits, context windows, GPU memory and model-serving failures.
- Network 35Refused connections, timeouts, resets, MTU problems and port exhaustion.
- Python 35Imports, virtual environments, encoding, concurrency and dependency conflicts.
- Kubernetes 34CrashLoopBackOff, ImagePullBackOff, OOMKilled, RBAC, scheduling and storage.
- Docker 27Daemon connectivity, disk space, image pulls, ports and architecture mismatches.
- System 26Disk space, systemd units, file descriptors, OOM killer and scheduled jobs.
- Cloud 25IAM permissions, quotas, service limits and credential failures.
- Security 25JWT validation, CSRF, OAuth grants, SELinux, SSH host keys and CSP.
- TLS 24Untrusted authorities, expiry, hostname mismatch, chains and cipher negotiation.
Something missing or wrong?
This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.