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

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.

Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: πŸ’‘ Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. πŸ–‹οΈ Sharing insights through technical writing, blogging, and open-source contributions. 🀝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. πŸš€ Launched Compose101 β€” a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart πŸŽ–οΈ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, currently working at Aircall. I'm open to work in various fields! Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code β€” but connecting product vision, technical execution, and business impact. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure 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 Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. 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)

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