Laravel Artisan CLI safely stop daemon queue workers
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
In today's fast-paced world of software development, it's essential to manage resources efficiently. One common concern is processing large numbers of jobs using queue workers in Laravel applications. While we can easily start and stop queue workers through maintenance mode or the --daemon flag, there might be situations where we need to kill the workers without affecting the rest of the application. This blog post will explore some safe ways to achieve this goal.
Option 1: Using Laravel's Maintenance Mode
php artisan down places the Laravel application in maintenance mode, which causes the currently running queue workers to stop processing jobs. However, it also prevents new requests from entering the system. By switching off maintenance mode with php artisan up, you can continue serving regular traffic while still allowing the existing queue workers to finish their current tasks and eventually die naturally.
Option 2: Manually Stopping Queue Workers
Warning: This method requires caution as it involves manually shutting down processes that could be in the middle of processing a job. If you're confident in your system and have taken necessary precautions, you can use the following steps to safely stop queue workers:
1. Locate the process IDs for each worker usingps aux | grep php. This command will list all PHP processes running on your server.
2. Identify the queue worker process IDs by looking for instances that contain "WorkQueue" in their process description.
3. Use the kill command to stop the individual worker processes, ensuring you only target the queue workers and not other important services or the web server itself: sudo kill -9 PID, where PID is the process ID of the specific worker.
4. Once all workers have been stopped, restart your Laravel application using the maintenance mode command (php artisan down) and then turn it off using php artisan up. This will ensure that new applications can reach your server while any remaining jobs in queues are processed.
Option 3: Using a Third-Party Package
Note: The Laravel team has not officially released any package to support this feature natively. However, you can find third-party packages on GitHub that aim to provide a safe method of stopping queue workers without affecting the application.
1. Search for relevant packages using your preferred search engine by entering a query like "laravel queue worker stop" or "laravel queue worker kill". 2. Evaluate the package's documentation and reviews to ensure it meets your requirements for safety and functionality. 3. Install the package using Composer:composer require vendor/package-name.
4. Follow the package's setup instructions, which may include creating a custom command or modifying existing controller or model files to implement the new features.
Conclusion: By exploring these options, you can find the most suitable way to safely stop Laravel queue workers without affecting the application. Remember to always back up your data and use caution when working with processes that can impact the integrity of your system. Happy coding!