Laravel Queue Connection Failed
The application cannot connect to the queue driver (Redis, SQS, database, etc.).
Explanation
Queue connection failed when Laravel cannot establish a connection to the configured queue driver. This commonly occurs with Redis queues when Redis is down, SQS when AWS credentials are invalid, or database queues when the database connection fails. The error message will indicate which driver was being used and why the connection failed. This prevents all queued jobs from being dispatched or processed until the connection is restored.
Common Causes
- Queue service is down
- Wrong queue driver configuration
- Invalid credentials for queue service
- Network connectivity issue
- Firewall blocking queue port
Solution
Verify the queue driver configuration in config/queue.php and .env (QUEUE_CONNECTION). For Redis queues, ensure Redis is running and accessible (check QUEUE_CONNECTION=redis and REDIS_HOST). For SQS, verify AWS credentials and queue URL. For database queues, ensure the jobs table exists and the database is accessible. Test the connection with redis-cli or telnet. Consider using a connection pool or retry mechanism for production. Implement failed job handling with php artisan queue:failed.
Code Example
// .env configuration for Redis queue
QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
// Test Redis connection in tinker
$redis = app('redis.connection');
ping();
// Dispatch job with retry
dispatch(new ProcessOrder($order))->onConnection('redis');
// Handle connection failure in job class
class ProcessOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;
public int $tries = 3;
public int $backoff = 60;
public function failed(Throwable $exception): void
{
// Called when job fails permanently
Log::error('Job failed: ' . $exception->getMessage());
}
}
Error Information
Language
php
Framework
laravel
Difficulty
Intermediate
Views
18
Related Errors
PHP
Include/Require File Not Found
The code tries to include or require a file that does not exist at the specified path.
Laravel
MalformedPayloadException
The request payload or session data is corrupted or invalid.
Database
Table Doesn't Exist
The SQL query references a table that doesn't exist in the database.
Database
Lock Wait Timeout Exceeded
A database query waited too long for a lock held by another transaction.