
In a previous article, How to Deploy Laravel to Shared Hosting (cPanel) in 2024: The Easy Way, we covered how to set up Laravel on cPanel. Once your Laravel app is running smoothly on shared hosting, the next step is likely setting up additional features like the Laravel Queues and Scheduler.
At first glance, you might think setting up Laravel queues on cPanel is as simple as adding cron jobs for the following commands:
php artisan schedule:run
php artisan queue:workBut this is where things can go wrong. I had the same thought and ran into an issue where the scheduler worked smoothly, but my queue jobs failed with the error:
“App\Jobs\GenerateContactEmail has been attempted too many times.”

If you’ve encountered similar problems, follow this step-by-step guide to set up your Laravel queues on cPanel correctly.
Before anything else, ensure that your Laravel project is deployed correctly. If you haven’t already, check out my detailed guide on How to Deploy Laravel to Shared Hosting (cPanel) in 2024: The Easy Way.
To schedule your Laravel tasks via cPanel’s cron job feature, follow these steps:
* * * * * /usr/local/bin/php /home/{accountName}/laravel/artisan schedule:runMake sure the PHP path
/usr/local/bin/phpand the Laravel project path/home/{accountName}/laravelare correct. These need to be absolute paths for the command to work.
Now, to set up the queue worker properly, you need to modify your app/Console/Kernel.php file.
Add this code inside the schedule() method:
$schedule->command('queue:work --stop-when-empty')
->everyMinute()
->withoutOverlapping();This ensures the queue worker runs every minute and prevents job overlaps by using the withoutOverlapping() method, so your queue jobs won’t be retried unnecessarily, which was causing the attempted too many times error.
App\Jobs\SendWelcomeEmail has been attempted too many times?This error usually occurs when the queue worker is overlapping, meaning the same job is being attempted multiple times before the previous instance completes. To prevent this, use the --stop-when-empty flag and the withoutOverlapping() method in your schedule() function within app/Console/Kernel.php.
--stop-when-empty flag do in Laravel queue work?The
--stop-when-emptyflag ensures that the queue worker stops after processing all jobs in the queue, which helps to avoid potential overlaps or unnecessary job retries.
Yes, while shared hosting like cPanel has limitations, by setting up cron jobs and using the proper configuration like
withoutOverlapping(), you can run Laravel queues and scheduler efficiently. However, for larger applications, a dedicated or cloud server might be more suitable.
php artisan queue:work on cPanel?No, once you configure the queue worker in the
schedule()function using cron jobs, it will run automatically. There’s no need to manually execute the command each time.