Errors / checked October 9, 2026
504: GATEWAY_TIMEOUT Code: FUNCTION_INVOCATION_TIMEOUT
The error
The response from a Vercel Function (often a cron route) that ran longer than its maximum duration.
Quick fix
- Raise maxDuration for that route (export const maxDuration = 60 in a Next.js route, or functions settings in vercel.json) up to your plan limit.
- Make the job smaller per call: process a batch (for example 100 rows) and return, and let the next scheduled call pick up the rest.
- Return 200 quickly and do the slow part in a background task or queue the platform supports.
Why this happens
Every Vercel Function has a maximum duration. Cron routes often do a whole day of work in one call, so they hit it first. Vercel does not retry a failed cron invocation.
Source: Vercel: Managing Cron Jobs (duration, error handling)
Other solutions
- Schedule the route more often with less work per call (every 5 minutes instead of once a night), which also needs a non-Hobby plan or an outside scheduler.
- Use a scheduler that retries: RunLater retries a timed-out or 5xx call with exponential backoff and logs each attempt, with a timeout you set from 1 to 300 seconds.
Check a schedule before you deploy it: the cron expression explainer shows the next 10 run times.
Have the URL called on schedule, with retries
RunLater calls your URL on a cron schedule or at an exact time, in your timezone, retries failed calls with backoff and logs each response, so a timeout or a 5xx shows up in a log instead of disappearing.
Start a 14-day trialStarter is $15/month for 250 scheduled requests and 25,000 runs. Cancel before day 14 and you pay nothing.