Skip to main content

Overview

The RedisConnection class manages the connection to Redis for BullMQ. It handles connection lifecycle, version checking, and script loading.
You typically don’t need to use this class directly. BullMQ classes like Queue and Worker handle connections automatically.

Constructor

opts
ConnectionOptions
required
Redis connection options (ioredis configuration or Redis instance)
extraOptions.shared
boolean
default:"false"
Whether this connection is shared
extraOptions.blocking
boolean
default:"true"
Whether this connection supports blocking operations
extraOptions.skipVersionCheck
boolean
default:"false"
Skip Redis version validation
extraOptions.skipWaitingForReady
boolean
default:"false"
Don’t wait for connection to be ready

Properties

client

Returns a promise that resolves to the Redis client.

status

The current connection status.

capabilities

Redis server capabilities based on version.

redisVersion

The detected Redis server version.

databaseType

The type of database being used.

Methods

disconnect

Disconnects from Redis.
wait
boolean
default:"true"
Whether to wait for disconnection to complete

reconnect

Reconnects to Redis.

close

Closes the connection.
force
boolean
default:"false"
Force close without waiting

Static Methods

waitUntilReady

Waits for a Redis client to be ready.

Static Properties

minimumVersion

Minimum required Redis version.

recommendedMinimumVersion

Recommended minimum Redis version.

ConnectionOptions

Using ioredis Options

Using Existing Redis Instance

Redis Cluster

Events

The RedisConnection class extends EventEmitter and emits the following events:

ready

Emitted when the connection is ready.

error

Emitted when a connection error occurs.

close

Emitted when the connection closes.

Version Requirements

BullMQ requires:
  • Minimum version: Redis 5.0.0
  • Recommended version: Redis 6.2.0 or higher
The connection will check the version automatically unless skipVersionCheck is enabled.

Important Notes

maxRetriesPerRequest

For blocking connections (Workers), BullMQ requires maxRetriesPerRequest: null:

Shared Connections

Multiple BullMQ instances can share the same Redis connection: