Summer sale! Save 50% on access to our entire library of courses.Join here →

Clearing Failed Jobs in Laravel

June 28th, 2024

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.

Thanks for reading! If you found this article helpful, you might enjoy our practical screencasts too.
Alex Garrett-Smith
Share :


No comments, yet. Be the first to leave a comment.

Tagged under