Bolt deployment

Vercel Serverless Function Timeout - API Routes Taking Too Long

API routes that work fine locally timeout on Vercel. Long-running tasks like file processing, bulk database operations, or external API calls exceed the timeout limit.

Requests return 504 Gateway Timeout and logs show the function was killed.

Error Messages You Might See

504 - Gateway Timeout FETCH_ERROR: request timeout Function timeout after 30s Vercel Serverless Function Error: timed out
504 - Gateway TimeoutFETCH_ERROR: request timeoutFunction timeout after 30sVercel Serverless Function Error: timed out

Common Causes

  1. Function execution time exceeds timeout (default 30s, max 60s on Pro)
  2. Waiting for slow external API calls without timeout
  3. Database query not optimized or hitting connection limits
  4. Large file processing happening synchronously
  5. Missing async/await causing hanging requests

How to Fix It

Upgrade to Vercel Pro for 60s limit (free tier is 30s max)

Add timeout to external calls: fetch(url, { timeout: 10000 })

Use background jobs for long tasks - trigger async processing, return immediately

Optimize DB queries: add indexes, use pagination for large result sets

Consider moving heavy lifting to cron jobs or separate worker services

Real developers can help you.

Victor Denisov Victor Denisov Developer Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's the maximum timeout on Vercel?

Free: 30s. Pro: 60s. Enterprise: up to 5min

How do I handle long-running tasks?

Trigger them asynchronously. Save a job record to DB, return immediately, process in background

Should I wait for all async tasks?

No! Return response to user, then run cleanup/processing. Use background jobs for long tasks

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help