Fix 'Build Exceeded Maximum Allowed Runtime' on Netlify
Also appears as:
- Build timed out
- Build exceeded the 30 minute timeout
- Exceeded build time limit
- Build cancelled due to timeout
Symptoms
- Build runs for a long time and then fails
- Build log shows progress but is killed before completion
- Large sites that previously built fine start timing out
- Timeout occurs during static page generation or image processing
What Causes This Error
Too many pages being statically generated
CommonFrameworks like Next.js, Gatsby, and Astro generate all static pages during the build. If you have thousands of pages, the generation process can exceed Netlify's 30-minute build limit.
Heavy image processing
CommonImage optimization during builds (resizing, format conversion, generating responsive sizes) is CPU-intensive. Sites with hundreds of images can hit the timeout during this step.
Slow external API calls during build
OccasionalIf your build fetches data from external APIs (CMS, databases, third-party services), slow or rate-limited responses can significantly extend build time.
Inefficient build configuration
OccasionalMissing build cache, unnecessary rebuilds, or redundant processing steps can all contribute to longer build times.
How to Fix It
Fix 1: Use incremental or on-demand generation
- Instead of generating all pages at build time, use ISR (Next.js), hybrid mode (Astro), or deferred static generation
- Generate only the most important pages at build time
- Let other pages be generated on the first request
// Generate only the top 100 posts at build time
export async function generateStaticParams() {
const posts = await getTopPosts(100)
return posts.map(post => ({ slug: post.slug }))
}
// Other posts will be generated on demand
export const dynamicParams = trueVerify: Rebuild and verify the build completes within the time limit.
Fix 2: Optimize image processing
- Pre-process images before they enter the build pipeline
- Use a CDN or image service (Cloudinary, Imgix) instead of build-time processing
- Reduce the number of generated image variants
- Compress source images to smaller dimensions
module.exports = {
images: {
// Use external image optimization
loader: 'custom',
loaderFile: './image-loader.js',
// Or disable optimization entirely for testing
// unoptimized: true,
},
}Verify: Check build logs to confirm image processing time is reduced.
Fix 3: Enable and optimize build caching
- Ensure Netlify's build cache is not disabled
- Use framework-specific cache plugins (gatsby-plugin-netlify, etc.)
- Cache external API responses locally during the build
- Avoid clearing the cache unnecessarily
Verify: Compare build times between cached and uncached builds.
Fix 4: Parallelize and batch API calls
- Use Promise.all() for concurrent API requests during builds
- Implement request batching for CMS queries
- Add local caching for API responses to avoid redundant calls
- Set reasonable timeouts on external API calls
// Instead of sequential:
const posts = await fetchPosts()
const authors = await fetchAuthors()
// Use parallel:
const [posts, authors] = await Promise.all([
fetchPosts(),
fetchAuthors(),
])Verify: Check build logs for reduced total API fetch time.
How to Prevent This
Profile your build time regularly — add timing logs to your build scripts to identify slow steps.
Use the Netli.fyi app to track build durations over time and catch regressions.
Implement incremental/on-demand generation from the start rather than waiting for timeouts.
Pre-process images before commit rather than during the build.
Consider splitting your site into multiple Netlify sites if it grows beyond what a single build can handle.

Developer Advocate at RevenueCat and creator of Netli.fyi. Building on Netlify since 2019. Writes from hands-on experience deploying dozens of production sites.
Manage Netlify on the go
Download Netli.fyi and monitor your sites, check deploys, and manage your projects from anywhere.