Error library

Vercel FUNCTION_INVOCATION_TIMEOUT (504 Gateway Timeout)

Vercel returns FUNCTION_INVOCATION_TIMEOUT (504) when a function runs longer than its allowed duration. Common causes are slow upstream calls, a code path that never returns a response, infinite loops, or unhandled exceptions.

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

Cause: The function exceeds its maximum duration or never sends a response.

How to fix it

  1. Check the function logs for the slow or hanging call.
  2. Make sure every code path returns a response, including errors.
  3. Add timeouts to external API/database calls.
  4. If work is legitimately long, raise the max duration within your plan or move it to background processing.

Example

Illustrative example, not from a customer project.

  export async function POST(req) {
    try { ... } catch (e) {
+     return Response.json({ error: 'failed' }, { status: 500 })
    }

FAQ

Is this a Vercel outage?

Usually not; it's the function exceeding its time limit.

Can I just increase the limit?

Within plan limits, yes, but fix hangs first.

QUICK FIX · $49 · THIS ERROR ONLY

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.

Bigger job: Getting the whole app live? Launch Path, $1,195 flat.

Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.

Check it yourself first, free

$49Fix this error