Overview
Every BullMQ class (Queue, Worker, QueueEvents) requires a connection to Redis. BullMQ uses ioredis under the hood, and connection options are passed directly to the ioredis constructor.If no connection options are provided, BullMQ defaults to
localhost:6379.Connection Options
BullMQ accepts connection configuration through theConnectionOptions interface:
Basic Connection
Reusing Connections
You can share an existing ioredis instance across multiple Queue instances to reduce connection overhead:Connection Behavior
Queue vs Worker Connections
The connection requirements differ between producers and consumers:- Queue (Producer)
- Worker (Consumer)
Use Case: Adding jobs via HTTP endpoints or API callsFor producers, use the default
maxRetriesPerRequest setting so operations fail quickly if Redis is unavailable.Important Configuration
maxRetriesPerRequest
This setting controls how many times ioredis retries a failed command:null(recommended for Workers): Retry indefinitely- Number (recommended for Queues): Retry N times before throwing an error
Redis Server Configuration
Key Prefix
Advanced Connection Options
Retry Strategy
Customize the retry backoff behavior:Redis Cluster
Connect to a Redis cluster:Connection Lifecycle
TheRedisConnection class manages connection state:
Waiting for Ready
All BullMQ classes expose awaitUntilReady() method:
Closing Connections
Always close connections gracefully:Version Requirements
- Minimum Redis Version: 5.0.0
- Recommended Redis Version: 6.2.0 or higher
- Dragonfly: Full support
- Valkey: Full support
Connection Events
Listen to connection events:Best Practices
Use Connection Pooling
Reuse connections when possible to reduce overhead, but create separate connections for blocking operations.
Set maxRetriesPerRequest
Use
null for workers (background) and a number for queues (foreground).Configure Redis Properly
Set
maxmemory-policy=noeviction and ensure sufficient memory.Monitor Connections
Track connection health and implement proper error handling.
Next Steps
Queues
Learn how to create and manage queues
Workers
Process jobs with workers
