Laravel's failover queue driver improves the reliability of queued job processing. It lets you define multiple queue connections in order of priority, so a job still gets queued even if the primary queue system is down.
In production environments, where uptime and consistent job delivery are critical, the failover driver can be a game-changer.
How the Failover Queue Driver Works
The failover driver acts as a wrapper around multiple queue connections. When a job is dispatched, Laravel will attempt to push it to the first connection in your list. If that connection fails — for example, if Redis is temporarily unavailable — Laravel automatically tries the next connection until the job is successfully queued.
This mechanism ensures high availability Laravel queues and protects your application from lost jobs or downtime.
Defining a Failover Queue Connection
You can configure the failover driver in your config/queue.php file. Here’s an example:
'connections' => [
'failover' => [
'driver' => 'failover',
'connections' => [
'redis',
'database',
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
],In this setup:
Laravel will first try Redis to push jobs.
If Redis is unavailable, the system will fall back to the database queue, providing a job queue redundancy mechanism.
Setting the Default Queue Connection
Once your failover driver is configured, you can set it as the default queue connection in your .env file:
QUEUE_CONNECTION=failoverThis ensures that all queued jobs automatically use the failover logic, improving reliable job processing in Laravel.
Running a Worker for Every Connection
The failover driver only decides where a job is pushed. Workers don't read from failover; they read from the real connections behind it. If you only run a Redis worker, every job that failed over sits in the jobs table until someone notices, which is the outage you were trying to avoid. Start at least one worker for each connection in the list:
php artisan queue:work redis
php artisan queue:work databaseGive both their own program in Supervisor (or whatever keeps your workers alive) so the database worker is already running when Redis goes down. If you use Horizon, remember it only manages Redis queues: run a plain php artisan queue:work database process alongside it. Connections on the sync, deferred or background drivers don't need a worker, since they run the job in the current PHP process.
Two more things worth knowing. When a push fails over, Laravel dispatches the Illuminate\Queue\Events\QueueFailedOver event, so listen for it and report it, or you won't know Redis was down. And failover only covers new pushes: jobs already sitting in Redis when it goes down stay there until it comes back.
When to Use the Failover Driver
The failover queue driver is ideal for:
Applications where job reliability is essential.
High-availability environments with multiple queue backends (Redis, SQS, Database).
Systems where downtime of one queue system should not interrupt job processing.
By using multiple connections, you ensure that your application can maintain continuous job dispatch even under failures.
Example: Dispatching Jobs With Failover
use App\Jobs\SendEmailJob;
SendEmailJob::dispatch($user)
->onConnection('failover');Laravel will automatically try to enqueue the job to Redis first. If Redis is down, it will failover to the database queue, ensuring no jobs are lost.
Benefits of the Failover Queue Driver
High reliability: Jobs are not lost if the primary queue fails.
Automatic fallback: Laravel seamlessly switches between connections.
Ease of configuration: Only a few lines in
queue.phpare needed.Production-ready: Ideal for applications that require robust job delivery.
Conclusion
Laravel’s failover queue driver ensures uninterrupted job dispatching by gracefully falling back to backup connections. This small configuration change significantly improves your application's queue system reliability, making it suitable for high-availability environments and critical job processing.
By implementing the failover driver, you gain a robust queue system that combines Redis speed with database reliability, ensuring continuous job delivery even during unexpected downtime.














