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
201
Related Errors
405
Laravel
MethodNotAllowedHttpException (405)
The HTTP method used is not allowed for the requested route.
429
Backend
Rate Limit Exceeded (429)
Too many requests were sent in a given amount of time.
503
DevOps
Service Unavailable (503)
The server is temporarily unable to handle requests due to overload or maintenance.
Database
PDOException (Database Connection)
PHP failed to connect to or communicate with the database server.