Skip to content

[ioredis] Unhandled error event: Error: All sentinels are unreachable. Retrying from scratch after 10ms. #2004

@0x0bit

Description

@0x0bit

In my application, this is how I set up ioredis.

{
  redis: {
      sentinels: [
        { host: '10.10.10.119', port: 26379 },
        { host: '10.10.10.120', port: 26379 },
        { host: '10.10.10.121', port: 26379 },
      ],
    
      name: 'mymaster',
      password: 'this is pass',
      options: {
        keyPrefix: 'txh:',
        sentinelConnectTimeout: 10000, 
        connectTimeout: 15000,
        retryStrategy(times) {
          if (times > 5) {
            return new Error('Retry limit reached');
          }
          const delay =  Math.min(retryAttempts * 1000, 10000);
          console.log(`Attempting to reconnect to Redis... Attempt #${times}, delay: ${delay}ms`);
          return delay;
        },
      }
    }
}

At times, I receive this error message.

[ioredis] Unhandled error event: Error: All sentinels are unreachable. Retrying from scratch after 10ms.
    at connectToNext (/usr/src/app/node_modules/ioredis/built/connectors/SentinelConnector/index.js:64:31)
    at SentinelConnector.connect (/usr/src/app/node_modules/ioredis/built/connectors/SentinelConnector/index.js:120:16)
    at /usr/src/app/node_modules/ioredis/built/Redis.js:121:64
    at new Promise (<anonymous>)
    at EventEmitter.connect (/usr/src/app/node_modules/ioredis/built/Redis.js:103:25)
    at Timeout._onTimeout (/usr/src/app/node_modules/ioredis/built/redis/event_handler.js:171:18)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

How should I handle it?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions