Hobby
- Default
- 300 seconds
- Maximum
- 300 seconds
- Extended maximum
- None
Fix Vercel 504 FUNCTION_INVOCATION_TIMEOUT: check maxDuration, plan limits, slow upstream calls and missing responses, with config for Next.js and vercel.json.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
FUNCTION_INVOCATION_TIMEOUT occurs "when a function invocation takes longer than the allowed execution time", and the status is 504 Gateway Timeout. The cause can be an error inside the function, a slow network call, or the environment the function runs in. The duration counts "time spent processing the request and sending the response, including streamed responses".Values above 800 seconds are beta, need function-level configuration, and apply only to listed runtime versions. Functions on the Edge runtime must begin sending a response within 25 seconds to keep streaming, and can stream for up to 300 seconds.
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 });
}{
"$schema": "https://openapi.vercel.sh/vercel.json",
"functions": {
"api/test.js": { "maxDuration": 30 },
"api/*.js": { "maxDuration": 15 },
"src/api/*.js": { "maxDuration": 25 }
}
}{
"$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.
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.
Open the /_logs path of the deployment URL, as Vercel describes, and look for the invocation that ran long.
Add timing logs around each database or API call. The one that eats most of the duration is the fix target.
Walk the handler. A branch that awaits a promise that never resolves, or ends without a Response, leaves the request open until the limit.
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://your-app.vercel.app/api/slowA 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.
4 questions people ask next, answered from the sources on this page.
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.
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.
Vercel documents it as 504 Gateway Timeout.
Vercel recommends Vercel Workflows for workloads that need unlimited execution time, since they can pause, resume and keep state without duration limits.
Run the free audit, then approve the fixes. Every change can be undone.