Vercel FUNCTION_INVOCATION_TIMEOUT (504) Next.js Origin: On your device Last updated 5 Nov 2026

Vercel: 504 GATEWAY_TIMEOUT — FUNCTION_INVOCATION_TIMEOUT: An error occurred with your deployment

A Vercel Serverless Function ran longer than its max duration, so Vercel killed it.

Exact message you may see 504: GATEWAY_TIMEOUT Code: FUNCTION_INVOCATION_TIMEOUTAn error occurred with your deployment FUNCTION_INVOCATION_TIMEOUTTask timed out after 10.01 seconds VercelVercel Runtime Timeout Error: Task timed out after
Seen on: Next.js

Meaning

Default limits are 10 s (Hobby) up to 60-300 s depending on plan/config. Raise export const maxDuration = 60 in the route (within your plan), speed up the work (indexes, parallel requests), or move long jobs to a queue/background function. Cold starts and slow DB connections also count.

Common causes

  • Slow database or external API
  • Heavy computation in the request
  • Cold start + connection setup
  • maxDuration left at default
  • No timeout/retry around upstream calls

⚡ Quick fix

  1. export const maxDuration = 60; in the route/page (plan-dependent)
  2. Optimise queries and parallelise requests
  3. Offload long tasks to queues/Cron/Workflow

Detailed fix by platform

Next.js

  1. export const maxDuration = 60; // seconds, route segment config

How to diagnose

  1. Duration — Over the limit?
  2. Cause — DB/API/CPU?
  3. Plan — Limit?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

504 — HTTP 504 Gateway Timeout (HTTP)504Edge Function size limit exceeded — Vercel: The Edge Function "middleware" size is 1.2 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size (Next.js)Edge Function size li…Failed to find Server Action — Next.js: Error: Failed to find Server Action "abc123". This request might be from an older or newer deployment (Next.js)Failed to find Server…next build: fetch failed ECONNREFUSED (build-time API) — Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 } (Next.js)next build: fetch fai…next build: JavaScript heap out of memory — Next.js: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (during next build) (Next.js)next build: JavaScrip…Prisma Client out of date on Vercel (prisma generate) — Vercel: PrismaClientInitializationError: Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client (Next.js)Prisma Client out of …Vercel FUNCTION_PAYLOAD_TOO_LARGE (413) — Vercel: 413 FUNCTION_PAYLOAD_TOO_LARGE — Request Entity Too Large (4.5 MB limit) (Next.js)Vercel FUNCTION_PAYLO…Vercel: Command "npm run build" exited with 1 — Vercel: Error: Command "npm run build" exited with 1 (Next.js)Vercel: Command "npm …Vercel FU…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.