← 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

How to fix it

  1. Find the slow call in the function logs (Vercel dashboard → Logs).

  2. Raise the limit for a route within your plan's allowed maximum:

    // app/api/generate/route.ts
    export const maxDuration = 60; // seconds
  3. Add timeouts to outbound fetches so they fail fast:

    await fetch(url, { signal: AbortSignal.timeout(10000) });
  4. Move long jobs to a background queue/cron, or stream the response.

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy