Skip to content
Latchkey

GitHub Actions "Cache not found for input keys" - Fix actions/cache Misses

actions/cache found no entry for your key. Usually the key changes on every run (so nothing ever matches), or there is no restore-keys fallback for a partial match.

What this error means

The Restore cache step logs "Cache not found for input keys" and the job rebuilds dependencies from scratch every time, even when nothing changed.

Actions log
Cache not found for input keys: npm-2f9c1a3b...
# next run uses a different hash, so it never hits

Common causes

Key changes on every run

A key built from github.sha or a timestamp is unique per run, so a restore can never match a prior save.

No restore-keys fallback

Without restore-keys, an exact-key miss falls all the way through instead of restoring a recent partial match.

Cache never saved on the base branch

Caches are scoped by branch; a PR can read the base/default-branch cache, but if nothing saved it there first, there is nothing to restore.

How to fix it

Key on the lockfile, not the SHA

Hash the dependency lockfile so the key is stable across runs that did not change dependencies, and add a restore-keys prefix.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('package-lock.json') }}
    restore-keys: |
      npm-

Seed the cache on the default branch

  1. Run the workflow on the default branch once so a cache is saved for PRs to restore.
  2. Confirm the save step actually ran (it is skipped on an exact-key hit).
  3. Keep the path the same between save and restore.

How to prevent it

  • Build cache keys from lockfile hashes, never from the commit SHA.
  • Always provide restore-keys for partial-match fallback.
  • Prefer setup-* actions with built-in caching where available.

Frequently asked questions

What causes ""Cache not found""?
A key built from github.sha or a timestamp is unique per run, so a restore can never match a prior save.
How do I fix "Cache not found"?
Hash the dependency lockfile so the key is stable across runs that did not change dependencies, and add a restore-keys prefix.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card