Skip to content
Latchkey

actions/cache@v4 "Cache restore failed: Bad gateway"

A 502 Bad gateway during cache restore is a transient cache-service error, not a configuration fault. The restore is skipped and, by default, the job continues with a cold cache.

What this error means

The cache step warns "Cache restore failed: Bad gateway" and proceeds without a restored cache.

github-actions
Warning: Cache restore failed: Cache service responded with 502 Bad gateway
Cache not found for input keys: deps-...

Common causes

Transient cache-service 502

The Actions cache backend returned a momentary gateway error.

Cache service degradation

Brief upstream degradation can make restores fail intermittently.

How to fix it

Tolerate the miss and re-run if needed

  1. Leave fail-on-cache-miss unset so a transient miss does not fail the job.
  2. Re-run the job; the cache service usually recovers quickly.
  3. Keep restore-keys so a partial-prefix restore can still help.
.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('package-lock.json') }}
    restore-keys: |
      npm-

How to prevent it

  • Do not set fail-on-cache-miss for best-effort caches.
  • Latchkey managed runners auto-retry transient cache-service failures (including 502s), so a Bad gateway on restore typically resolves without a manual re-run.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →