Skip to content
Docs

How can I set a custom build timeout?

Wrap your Vercel build command with the timeout command to ensure builds terminate gracefully before exceeding Vercel’s maximum build duration.

To kill builds before they timeout due to Vercel’s maximum build duration, wrap the existing build command with the timeout command. This method ensures that your builds are terminated gracefully, preventing unnecessary resource usage.

Copy link to heading1. Identify Your Build Command

The existing build command can be found via Build and Deployment Settings, or the buildCommand value in a previously configured vercel.json file.

If you haven’t set one, it will be your framework’s default build command.

Copy link to heading2. Modify the Build Command

To set a custom build timeout, modify your build command to include the timeout command followed by the desired time limit. The syntax for the timeout command is:

timeout [DURATION] [COMMAND]

DURATION is a floating point number with an optional suffix: 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. A duration of 0 disables the associated timeout.

To set a 15-minute timeout for a Next.js build, your modified build command would be:

timeout 15m next build

Copy link to heading3. Observe the Result

The next time your build command runs for longer than this duration, it will receive a 124 exit status, which looks like this in your build log:

Error: Command "timeout 15m next build" exited with 124

Related documentation

More Builds guides