Laravel queue process timeout error
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Solving Laravel Queue Timeout Errors: A Comprehensive Guide for Developers
Body:
Laravel's queues allow developers to handle time-consuming tasks without affecting the user experience or server performance, making it a powerful tool in your software development arsenal. However, you may encounter issues where jobs take longer than expected and cause queue process timeout errors. In this blog post, we will explore how to address these issues while maintaining the efficiency of Laravel queues.
Understanding Queue Process Timeout Errors
The Laravel framework uses a symphony component, Symfony\Component\Process, which has a timeout mechanism. The default timeout value is 60 seconds, and if the process exceeds this threshold without producing any output, an error is returned. This behavior ensures that your application does not get stuck or becomes unresponsive due to a long-running job.Increasing the Default Timeout Value
You can override the default timeout value using the following command:php artisan queue:listen --timeout=120. This increases the timeout limit from 60 seconds to 120 seconds, giving your task more time to complete. However, this is not always an ideal approach as it may result in real job failures or resource waste if they don't need so much time.
Using set_time_limit()
Another approach is setting a new PHP execution timeout within your Laravel application using theset_time_limit() function. Adding this line of code at the beginning of your queue job's class will extend the default time limit: set_time_limit(360); // 1 hour.
Accessing the Process Object's Timeout Setting
Although the Symfony\Component\Process\Exception\ProcessTimedOutException error is not raised within your own job code, you can still access and manipulate the timeout settings of the underlying process. The following example shows how to extend the timeout:use Symfony\Component\Process\Process;
class MyJob extends Job {
public function handle()
{
$process = new Process('myCommand'); // Replace with your actual command
$process->setTimeout(null); // Set the timeout to unlimited (no timeout)
$exitCode = $process->run();
if ($exitCode !== 0) {
throw new \Exception("The command returned a non-zero exit code.");
}
}
}