Vercel: 504 GATEWAY_TIMEOUT — FUNCTION_INVOCATION_TIMEOUT: An error occurred with your deployment
A Vercel Serverless Function ran longer than its max duration, so Vercel killed it.
504: GATEWAY_TIMEOUT Code: FUNCTION_INVOCATION_TIMEOUTAn error occurred with your deployment FUNCTION_INVOCATION_TIMEOUTTask timed out after 10.01 seconds VercelVercel Runtime Timeout Error: Task timed out after Meaning
Default limits are 10 s (Hobby) up to 60-300 s depending on plan/config. Raise export const maxDuration = 60 in the route (within your plan), speed up the work (indexes, parallel requests), or move long jobs to a queue/background function. Cold starts and slow DB connections also count.
Common causes
- Slow database or external API
- Heavy computation in the request
- Cold start + connection setup
- maxDuration left at default
- No timeout/retry around upstream calls
⚡ Quick fix
export const maxDuration = 60;in the route/page (plan-dependent)- Optimise queries and parallelise requests
- Offload long tasks to queues/Cron/Workflow
Detailed fix by platform
Next.js
export const maxDuration = 60; // seconds, route segment config
How to diagnose
- Duration — Over the limit?
- Cause — DB/API/CPU?
- Plan — Limit?
🔧 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
- 504 HTTP 504 Gateway Timeout
- Edge Function size limit exceeded Vercel: The Edge Function "middleware" size is 1.2 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size
- Failed to find Server Action Next.js: Error: Failed to find Server Action "abc123". This request might be from an older or newer deployment
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