Laravel 4 - retry all failed jobs
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
In any application development process, managing tasks efficiently is crucial. One such task might be scheduling jobs that need to run repeatedly over time. Laravel provides a powerful queue mechanism, but sometimes, errors may occur during job execution, leading to failure. In this post, we will discuss how to retry all failed jobs from the failed_jobs table in Laravel 4 efficiently.
Understanding the Default Queue Retry Functionality
Laravel's queue system has a built-in mechanism to handle failure cases. The retry function allows you to reattempt jobs that failed due to errors or other issues. The default retry behavior can be configured in the Laravel configuration file (config/queue.php). Here, you can define the number of attempts at which a job should fail permanently and the interval between each attempt for the remaining retries.Retrying Individual Failed Jobs
You can retry failed jobs one at a time using the `queue:retry` Artisan command. This method allows you to specify the job ID, which will trigger its retry process. It is helpful when handling specific errors or troubleshooting individual issues.shell
php artisan queue:retry 5Retrying All Failed Jobs Simultaneously
However, handling large numbers of failed jobs individually might be time-consuming and can cause additional strain on your development workflow. To address this issue, you can use the Laravel Eloquent model to retrieve all failed jobs in bulk and then retry them simultaneously.php
use \Illuminate\Queue\Interfaces\FailedJob;
use Illuminate\Database\Eloquent\Collection;
// Retrieve all failed jobs from the database
$failedJobs = FailedJob::all();
// Prepare a collection of job instances to be retried, by casting the list of `FailedJob` models to an array and then initializing the collection with that array
$jobInstancesCollection = Collection::make(array_map('function' => static function ($failedJob) { return $failedJob->job; }, $failedJobs));
// Retry all jobs in the collection with the `retry` method from the QueueManager class
\App\QueueManager::retry($jobInstancesCollection);