How to Fix Vercel: 504 Gateway Timeout
Last reviewed
Error message
504: GATEWAY_TIMEOUT — request to a Vercel function did not complete in time.
504 from Vercel is a server-side timeout — different from 408 (client-side). The fix is at your function or upstream.
What this error means
Vercel routed your request to a function or upstream, but the response didn't come back within the platform's gateway timeout.
Why this happens
Almost always: a slow function (database, external API), a function that hit its maxDuration, or a misconfigured rewrite pointing at a slow origin.
Quick fix (for end users)
- Check the function logs in the Vercel dashboard to see how long requests are taking.
- Speed up the slow path or cache results.
Admin / engineer fix
Increase function maxDuration if your plan allows.
command// app/api/route.ts export const maxDuration = 30;Add caching (revalidate, Redis, Vercel KV) for expensive operations.
If using rewrites to an upstream, make sure the upstream is fast and reachable.
Step-by-step fix
Identify the slow function from logs.
Profile and optimize, or add caching.
Increase maxDuration if needed and your plan allows.
Affected products
Vercel
Common variations of this error
People also see these phrasings of the same problem:
504 GATEWAY_TIMEOUT VercelFunction timeout 504
Still broken? Try these
- Check the upstream's own status page.
- Run the function locally with realistic data to confirm timing.
Related errors
Related searches
- vercel 504 gateway timeout
- vercel function performance
Frequently asked questions
What does "Vercel: 504 Gateway Timeout" mean?
Vercel routed your request to a function or upstream, but the response didn't come back within the platform's gateway timeout.
What causes "Vercel: 504 Gateway Timeout"?
Almost always: a slow function (database, external API), a function that hit its maxDuration, or a misconfigured rewrite pointing at a slow origin.
How do I fix "Vercel: 504 Gateway Timeout"?
1. Identify the slow function from logs. 2. Profile and optimize, or add caching. 3. Increase maxDuration if needed and your plan allows. Always test changes in a non-production environment first.
Browse more errors in Vercel: Fix Vercel deployment errors. Build failures, missing output directories, exceeded build duration, missing env vars, and module resolution issues. Or paste your own error into the error decoder tool to find a match. You can also go back to the homepage to browse common errors by topic.