How can I set a custom build timeout?

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.

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.

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

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

Couldn't find the guide you need?