Next.js: Failed to set Next.js data cache for https://api.example.com/data, items over 2MB can not be cached (2437412 bytes)
A fetch response was too large for Next.js's data cache (limit 2 MB), so it wasn't cached.
Failed to set Next.js data cache, items over 2MB can not be cachedFailed to set Next.js data cache for https://api.example.com/data, items over 2MB can not be cachedFailed to set Next.js data cache items over 2MB can not be cached (2437412 bytes)items over 2MB can not be cached Meaning
Only the caching fails; the request still works. To fix: fetch less data (pagination, field selection), cache your own processed result in a smaller form, use cache: 'no-store' for large responses, or store large payloads in a database/blob and cache the reference.
Common causes
- Large API/CMS responses
- Fetching whole collections
- Unpaginated lists
- Data containing images/base64
- Duplicate large fetches
⚡ Quick fix
- Request only needed fields/pagination
- Use
cache: "no-store"for large responses - Cache a reduced version via your own cache (Redis, KV)
Detailed fix by platform
Next.js
await fetch(url, { cache: "no-store" })to avoid the cache attempt
How to diagnose
- Size — Response bytes?
- Need — All fields?
- Alternative — Own cache?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- Dynamic server usage Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`
- next build: fetch failed ECONNREFUSED (build-time API) Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 }
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026