Vercel FUNCTION_INVOCATION_TIMEOUT (504) Error
Ongoing Web (Vercel Functions) Updated October 21, 2026
Quick answer
A 504 FUNCTION_INVOCATION_TIMEOUT means your function ran past its max duration (300s default with Fluid compute). Make sure every code path returns a response, move the function region next to your database or API, and raise maxDuration on Pro (up to 800s).
Most likely fix: Make every path return a response.
Symptoms
Requests hang and return '504: GATEWAY_TIMEOUT' with code FUNCTION_INVOCATION_TIMEOUT, often only in production or under load.
Why it happens
- Slow database or third-party API calls
- Code path that never sends a response (missing return, unresolved promise)
- Function region (default iad1) far from the database or API
- Long jobs that do not fit in a request
- Old projects without Fluid compute still on lower limits
How to fix it
Try these in order — the most common fix is first.
1. Make every path return a response
- Check Logs for the timed-out request
- Wrap handlers in try/catch and always return a Response
- Add timeouts to fetch and database calls
2. Move the function region next to your data
- Settings > Functions > Function Region
- Choose the region closest to your database or main API
- Redeploy
3. Raise maxDuration (Pro/Enterprise)
- Enable Fluid compute in Settings > Functions if it is off
- In a Next.js route add: export const maxDuration = 800
- Or set functions.maxDuration in vercel.json
- Hobby is capped at 300 seconds
4. Move long work out of the request
- Return a response immediately and process in the background
- Use Vercel Workflows or a queue for jobs longer than a few minutes
- Stream responses for long AI generations
This guide also covers
- vercel function timeout
- function_invocation_timeout vercel
- vercel 504 gateway timeout
- vercel serverless function timeout
- vercel maxduration
Still not working?
If Vercel keeps failing, you're not alone. See every Vercel problem users report or the alternatives people switch to.
Other Vercel errors
- Vercel Deployment Failed: Build Error
- Vercel 404 NOT_FOUND After Deploy
- Vercel Build Exceeded Memory (SIGKILL / Out of Memory)
- Vercel Environment Variables Not Working (Undefined)
- Vercel Domain Not Verifying (Invalid Configuration)
- Vercel Unexpected Bill: Why Usage Charges Spiked
- Vercel Deployment Blocked: Commit Author Does Not Have Access
- Vercel Not Deploying After Git Push
- Vercel ERR_TOO_MANY_REDIRECTS With Cloudflare
- Vercel 500 FUNCTION_INVOCATION_FAILED Error
- Vercel 413 FUNCTION_PAYLOAD_TOO_LARGE (4.5 MB Limit)
- Vercel Project Paused or Account Blocked