← All errors · Vercel
FUNCTION_INVOCATION_TIMEOUT (504)
Exact error
504: GATEWAY_TIMEOUT. Code: FUNCTION_INVOCATION_TIMEOUT
What it means
A serverless function ran longer than its allowed maximum duration and was stopped.
Likely causes
- Slow external API or database queries.
- Awaiting a promise that never resolves.
- Doing long jobs (AI generation, scraping, big imports) inside a single request.
How to fix it
Find the slow call in the function logs (Vercel dashboard → Logs).
Raise the limit for a route within your plan's allowed maximum:
// app/api/generate/route.ts export const maxDuration = 60; // secondsAdd timeouts to outbound fetches so they fail fast:
await fetch(url, { signal: AbortSignal.timeout(10000) });Move long jobs to a background queue/cron, or stream the response.
Related errors
Get new fixes weekly
No spam. Unsubscribe anytime. Privacy