Free auditStart free
GuideError · CDN and hosting errors

Vercel FUNCTION_INVOCATION_TIMEOUT

Fix Vercel 504 FUNCTION_INVOCATION_TIMEOUT: check maxDuration, plan limits, slow upstream calls and missing responses, with config for Next.js and vercel.json.

3 min
read
5
sources
Nov 1, 2026
updated
Scaplet Editorial Team
author
In one line

Vercel returns a 504 FUNCTION_INVOCATION_TIMEOUT when a function runs longer than its allowed duration. With Fluid compute the default is 300 seconds on every plan, and the maximum is 300 seconds on Hobby and 800 seconds on Pro and Enterprise. Find the slow call or the missing response, or set maxDuration within your plan's limit.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Causes and fixes

The four causes Vercel lists

Cause

The function is taking too long

What to check
API and database calls against your plan's duration limit
Fix
Speed them up, or consider Fluid compute for longer durations; use Vercel Workflows for unlimited execution time
Cause

The function is not returning a response

What to check
Every code path ends in a returned HTTP response, even an error
Fix
Return a response on all paths. Without one the function times out
Cause

An infinite loop

What to check
Loops and retries that can never finish
Fix
Fix the loop
Cause

Upstream errors

What to check
The external API or database you call
Fix
Check it for errors
03Fix it on your stack

Set maxDuration, by framework

Next.js app router: app/api/my-function/route.ts
export const maxDuration = 5; // This function can run for a maximum of 5 seconds

export function GET(request: Request) {
  return new Response('Vercel', { status: 200 });
}
vercel.json: other frameworks, older Next.js, Rust, Go, Python or Ruby
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "functions": {
    "api/test.js": { "maxDuration": 30 },
    "api/*.js": { "maxDuration": 15 },
    "src/api/*.js": { "maxDuration": 25 }
  }
}
vercel.json: a Python framework app keys on its entrypoint
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "functions": {
    "app/main.py": { "maxDuration": 60 }
  }
}

Vercel notes that the order of file patterns matters, and that a Next.js project using a src directory must prefix function routes with /src/. You can also set a project default in the dashboard under Settings, then Functions, in the Function Max Duration section. A function that runs longer than its set maximum is terminated, so choose a value that allows normal work, including streamed responses, without letting a runaway run long.

04How it works

Check it in 2 minutes

  1. 1

    Reproduce with timing

    Run curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://your-app.vercel.app/api/slow. A 504 after your configured duration confirms the timeout and tells you which limit applied.

  2. 2

    Read the logs

    Open the /_logs path of the deployment URL, as Vercel describes, and look for the invocation that ran long.

  3. 3

    Time the slow call

    Add timing logs around each database or API call. The one that eats most of the duration is the fix target.

  4. 4

    Confirm every path returns

    Walk the handler. A branch that awaits a promise that never resolves, or ends without a Response, leaves the request open until the limit.

Time the endpoint
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://your-app.vercel.app/api/slow
05Explained

What a 504 means for crawling

A 504 is a 5xx to Google. Googlebot slows down on 5xx and 429, keeps indexed URLs for a time, and "eventually" drops them if the errors persist. Keep pages that should rank well inside the duration limit, and see timeout errors for finding affected URLs.

Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01What is the Vercel function timeout?

With Fluid compute, 300 seconds by default on Hobby, Pro and Enterprise. The maximum is 300 seconds on Hobby and 800 seconds on Pro and Enterprise, with a beta extended maximum of 1800 seconds for supported runtimes on Pro and Enterprise.

02How do I fix FUNCTION_INVOCATION_TIMEOUT?

Find what makes the function slow: an upstream call, a missing return, a loop or an unhandled exception. Then fix it or raise maxDuration within your plan limit, using export const maxDuration in the route or functions in vercel.json.

03Is FUNCTION_INVOCATION_TIMEOUT a 504 or a 500?

Vercel documents it as 504 Gateway Timeout.

04What should I use for work longer than the maximum?

Vercel recommends Vercel Workflows for workloads that need unlimited execution time, since they can pause, resume and keep state without duration limits.

Sources · 5

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • vercel.com
  • google.com
  • mozilla.org
  1. 01Vercel Docs: FUNCTION_INVOCATION_TIMEOUTvercel.com · checked 2026-11-01
  2. 02Vercel Docs: Configuring maximum duration for Vercel Functionsvercel.com · checked 2026-11-01
  3. 03Vercel Docs: Vercel Functions limitsvercel.com · checked 2026-11-01
  4. 04How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
  5. 05MDN: 504 Gateway Timeoutdeveloper.mozilla.org · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane