Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retry all failed jobs from Redis queue in Laravel Horizon

How can you retry all failed jobs in Laravel Horizon? There appears to be no "Retry All" button and the artisan command doesn't work as the failed jobs aren't stored in a table.

like image 731
Dally Avatar asked Oct 14 '25 17:10

Dally


2 Answers

The queue:retry command accepts all in place of an individual job ID:

php artisan queue:retry all

This will push all of the failed jobs back onto your redis queue for retry:

The failed job [44] has been pushed back onto the queue!
The failed job [43] has been pushed back onto the queue!
...

If you didn't create the failed logs table according to the installation guide with:

php artisan queue:failed-table
php artisan migrate

Then you may be up a creek. Maybe try interacting with redis manually and trying to access the list of failed jobs directly (assuming the failed jobs entries haven't been wiped - looks like they default to persisting in redis for a week, based on the config settings in config/horizon.php).

like image 156
kjones Avatar answered Oct 17 '25 07:10

kjones


as the failed jobs aren't stored in a table

Actually, you should create that table. From the Laravel Horizon documentation:

You should also create the failed_jobs table which Laravel will use to store any failed queue jobs:

php artisan queue:failed-table

php artisan migrate

Then, to retry failed jobs:

Retrying Failed Jobs

To view all of your failed jobs that have been inserted into your failed_jobs database table, you may use the queue:failed Artisan command:

php artisan queue:failed

The queue:failed command will list the job ID, connection, queue, and failure time. The job ID may be used to retry the failed job. For instance, to retry a failed job that has an ID of 5, issue the following command:

php artisan queue:retry 5
like image 39
Kenny Horna Avatar answered Oct 17 '25 06:10

Kenny Horna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!