Netlify Function Timeout (502 / 504)
Quick answer
Synchronous Netlify functions stop after 60 seconds and buffered responses max out at 6 MB. Move long work to a background function (15 minutes) or split it up.
Most likely fix: Use a background function
How to fix it
Try these in order — the most common fix is first.
1. Use a background function
- Name the file with the -background suffix; it runs up to 15 minutes but returns 202 immediately
- Store results in a database or blob store and poll
Did this fix it?2. Stream large responses
- Return a streamed response (up to 20 MB)
Did this fix it?3. Speed up the work
- Parallelize upstream calls, cache results, add timeouts to fetch
Did this fix it?4. Use a scheduled function for cron work
- Scheduled functions allow 30 seconds
Did this fix it?5. Raise memory/vCPU on Pro
- Set memory up to 4096 MB in config on credit-based Pro (cost scales)
Did this fix it?6. Check logs
- Open Logs > Functions to see the failing invocation
Did this fix it?
Symptoms
Requests return 502/504 or 'Task timed out' after about a minute, or large responses fail.
Why it happens
- Work exceeds the 60-second synchronous limit
- Payload above 6 MB buffered / 4.5 MB binary
- Slow upstream API
- Cold start plus heavy work
- Proxied requests time out after 26 seconds
This guide also covers
- netlify function timeout
- netlify function 502
- netlify task timed out
- netlify function 10 seconds
Still not working?
If Netlify keeps failing, you're not alone. See every Netlify problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
Other Netlify errors
- Netlify Page Not Found on Refresh (SPA 404)
- Netlify Build Failed
- Netlify Deploy Stuck on Building or Enqueued
- Netlify Custom Domain Not Working
- Netlify SSL Certificate Pending or Not Provisioning
- Netlify Site Paused: Credit Limit Reached
- Netlify Build Failed: Secrets Scanning Detected Secrets
- Netlify Environment Variables Undefined