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.

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 Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience David Olverson David Olverson Solo dev shipping production apps with AI-assisted development. I specialize in rescuing broken Lovable/Bolt/Cursor builds and taking them to production. 10+ apps shipped including SaaS CRMs, gaming platforms, real estate tools, and Discord bots. Stack: Next.js 16, TypeScript, Tailwind CSS, FastAPI, PostgreSQL, Prisma. I use Claude Code with 50+ custom skills for rapid delivery. Average turnaround: 2-4 weeks from broken prototype to production. 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. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. 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.

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