1. [Home](https://quorumauth.com/) /
2. [Guides](https://quorumauth.com/guides/) /
3. Fixing "kid not found" when verifying a JWT against a JWKS

Guides · QuorumAuth

# Fixing "kid not found" when verifying a JWT against a JWKS

> JWT verification fails because the kid is not in the JWKS? Find which of five causes you have, check it in two commands, and fix the verifier for good.

Your service rejects tokens that look fine, and the log says the key ID is not in the key set. It is almost always one of five causes, and one of them means the rejection is correct.

Updated November 10, 2026

A JWKS is the board of stamps a guard checks wristbands against. "Kid not found" means the wristband names a stamp the guard's copy of the board does not show. Either the guard's copy is old, the guard is reading another club's board, the stamp was cancelled, or the wristband is fake.

On this page

1. The symptom
2. Five causes, from most to least common
3. Check it in two minutes
4. Fix the verifier, not the incident
5. How QuorumAuth avoids it
6. Where to go next

## The symptom

Tokens that worked an hour ago now fail, or tokens from one environment fail in another. Libraries phrase it differently: “kid not found”, “no matching key”, “unable to find a signing key”. They all mean the same thing: the token’s header names a key ID (`kid`) that is not in the [JSON Web Key Set](https://quorumauth.com/learn/what-is-a-jwks/) your verifier holds.

The fix depends on why. Retrying blindly, or switching off the check, turns a key-distribution bug into a security hole.

## Five causes, from most to least common

1. **Stale cache after a rotation.** The issuer published a new key and signs with it. Your verifier fetched the set once at startup and never again.
2. **Wrong key set.** The token comes from another issuer than the one whose set you load: staging against production, one tenant or organization against another, or a hard-coded URL that no longer matches the issuer.
3. **A withdrawn key.** After an emergency rotation, the issuer stops publishing the old key. Tokens it signed should fail. This one is not a bug.
4. **A forged or malformed token.** Anyone can write any `kid` into a header. If such tokens make your verifier refetch every time, they double as a way to flood the issuer.
5. **A failed fetch reported as a missing key.** A timeout or TLS error while loading the set leaves the verifier with no keys, and some code paths report that as “kid not found”.

Finding which cause you have

1. Decode header and iss → Expected issuer?
2. Expected issuer? → Wrong key set no
3. Expected issuer? → kid in live set?yes
4. kid in live set? → Stale cache: refetch yes
5. kid in live set? → Withdrawn or forged: refuse no

A decision flow. Decode the token header. If the issuer is not the one you expect, you are reading the wrong key set. If the kid is in the issuer's current key set, your cache is stale. If the kid was in an earlier key set and is gone, the key was withdrawn and the refusal is correct. Otherwise the token names a key the issuer never published.

Two values from the token header and one from the issuer's key set settle most cases.

## Check it in two minutes

Decode the header without verifying it, then compare with what the issuer publishes. Replace the placeholders with your token and issuer.

```
# 1. What the token claims: kid and alg in the header, iss in the payload
TOKEN='<your token>'
for part in 1 2; do
  s=$(printf %s "$TOKEN" | cut -d. -f"$part" | tr '_-' '/+')
  while [ $(( ${#s} % 4 )) -ne 0 ]; do s="$s="; done
  printf %s "$s" | base64 -d; echo
done

# 2. What the issuer publishes right now
ISSUER='<issuer URL from your configuration>'
JWKS_URI=$(curl -fsS "$ISSUER/.well-known/openid-configuration" | jq -r .jwks_uri)
curl -fsS "$JWKS_URI" | jq -r '.keys[].kid'
```

- `iss` differs from your configured issuer: cause 2.
- The `kid` is in the live set: cause 1, or cause 5 if your logs show a failed fetch.
- The `kid` is not in the live set: cause 3 or 4. Refuse the token.

## Fix the verifier, not the incident

- **Refetch once on an unknown `kid`, rate limited.** A rotation then heals itself on the first new token, and a forged one cannot make you fetch on demand.
- **Take the key set location from configuration or discovery.** Read the issuer from your configuration and the `jwks_uri` from its [discovery document](https://quorumauth.com/learn/what-is-oidc-discovery/). Never from the token.
- **Check `iss` before you look up the key.** A token from an issuer you do not trust should fail as such, not as a missing key.
- **Report fetch failures as unavailable.** “I could not load the keys” and “this token is invalid” need different alerts and different retries.
- **On the issuer side, overlap keys.** Publish the new key before signing with it, and keep the old one until its last token expires, unless you are withdrawing it on purpose.

A verifier that survives rotation

1. 1 Verifier → Verifier Known kid: verify from cache No request
2. 2 Verifier → Issuer key set Unknown kid: fetch once
3. 3 Issuer key set → Verifier Current keys, new kid included
4. 4 Verifier → Verifier Forged token: refuse No further fetch

A sequence between a verifier and an issuer's key set. The verifier verifies a token whose kid it holds from cache, with no request. The issuer rotates. A token arrives naming the new kid; the verifier fetches the key set once and verifies. A forged token arrives; it is refused on the key it names, without fetching again.

A known key costs nothing; an unknown key costs one fetch; a forged one costs no fetch at all.

## How QuorumAuth avoids it

QuorumAuth signs the tokens and runs the verifier side in its SDK, so the behaviour above is built in. In its tested behaviour:

- **One issuer per organization.** Each organization is its own OpenID Provider, with an issuer that never changes when the organization is renamed and a `jwks_uri` holding exactly the keys that organization publishes. An organization that does not exist has no issuer and no key set.
- **Known keys cost nothing.** A key ID the SDK already holds is answered without contacting the authority, and later verifications for the same organization come from cache.
- **Unknown keys cost one fetch.** After a rotation, a key the SDK has never seen costs exactly one immediate discovery round-trip.
- **Forged tokens cost no fetch.** A tampered token is refused on the key it names, and the SDK fetches no further keys.
- **Withdrawal is explicit.** An emergency rotation names the key it withdraws, and the published key set no longer contains it. A refused rotation withdraws nothing.
- **Failures say what failed.** Discovery refuses a key set carrying private key material, refuses a peer that is not the expected authority, and when discovery is unreachable it fails closed and names the connection failure.

Keys are only half of token trust. To stop a token whose key is still valid, see [how to revoke a JWT before it expires](https://quorumauth.com/guides/revoke-jwt-before-expiry/).

## Where to go next

For the key set format and rotation routine, read [what a JWKS is](https://quorumauth.com/learn/what-is-a-jwks/). For services that sign their own requests, read about [JWT client assertions](https://quorumauth.com/learn/what-is-jwt-client-assertion/). For the whole machine-to-machine picture, see [the machine-to-machine authentication platform](https://quorumauth.com/solutions/machine-to-machine-authentication-platform/).

## Frequently asked questions

Why does "kid not found" start right after a key rotation?

Your verifier cached the old key set and does not refetch when a token names a key it has never seen. Refetch once on an unknown kid, with a rate limit.

Should I refetch the JWKS every time verification fails?

No. A forged token can name any kid it likes, so unlimited refetching lets anyone make you hammer the issuer. Refetch once per unknown kid, rate limited, and refuse after that.

Can I read the JWKS URL from the token?

No. Take it from your configuration or the issuer's discovery document. A key location chosen by the token lets the token choose who it trusts.

Is "kid not found" ever the right answer?

Yes. After an emergency rotation, tokens signed with the withdrawn key should fail. So should tokens from an issuer you do not trust.

## Related reading

[Learn QuorumAuth What is a JWKS?A JWKS publishes the public keys that verify an issuer's tokens. Learn the RFC 7517 format, how kid lookup and rotation work, and common mistakes.Read](https://quorumauth.com/learn/what-is-a-jwks/) [Learn QuorumAuth What is OIDC discovery?OIDC discovery lets an app configure itself from one issuer URL. What /.well-known/openid-configuration contains, how clients use it, and what to check.Read](https://quorumauth.com/learn/what-is-oidc-discovery/) [Learn QuorumAuth What is a JWT client assertion?A client assertion is a signed JWT an OAuth client sends instead of a client secret. How RFC 7523 works, the client\_assertion\_type value, and what to check.Read](https://quorumauth.com/learn/what-is-jwt-client-assertion/) [Guides QuorumAuth How to revoke a JWT before it expires A leaked or unwanted JWT stays valid until exp unless every verifier learns otherwise. Compare four ways to revoke one early, and what each costs you.Read](https://quorumauth.com/guides/revoke-jwt-before-expiry/) [Solutions QuorumAuth Machine to machine authentication Authenticate services, jobs and scripts with scoped, revocable, short-lived tokens instead of long-lived API keys that leak and never get rotated.Read](https://quorumauth.com/solutions/machine-to-machine-authentication-platform/)

## Talk to sales about QuorumAuth.

QuorumAuth is sold through our sales team. The Build page shows the drop-in sign-in on your origin and how to reach sales about your stack.

[Go to Build and contact sales →](https://quorumauth.com/onboarding/)
