Clearing Failed Jobs in Laravel

June 28th, 2024 • 1 minute read time

We don't often want failed jobs to hang around in our Laravel queues once we've fixed an issue or re-tried a job. Let's look at flushing our queue whether you use Horizon or not.

To clear failed jobs in Laravel, use the php artisan queue:flush command:

php artisan queue:flush

There aren't many options to pass to this command, except hours, which allows you to specify the number of hours to retain failed job data.

Simple! But, if you're using Laravel Horizon, the queue:flush command won't remove failed jobs.

Failed jobs are automatically cleared after 7 days if you use Horizon, but if you need to clear all failed jobs immediately, use the horizon:forget command with the --all option:

php artisan horizon:forget --all

If you need to clear a specific job, you can pass in the UUID of the failed job you'd like to remove:

php artisan horizon:forget 'ccf69080-e78d-4dbf-89b0-66ea64c6859e'

You'll be able to find the job UUID within your Horizon dashboard.

If you found this article helpful, you'll love our practical screencasts.
Author
Alex Garrett-Smith
Share :

Comments

No comments, yet. Be the first!

Table of contents

Tagged under