{"record":{"id":"ddbddb5e4168a320","repo":"redis/node-redis","slug":"couldn-t-connect-to-any-sentinels","errorCode":null,"errorMessage":"couldn't connect to any sentinels","messagePattern":"couldn't connect to any sentinels","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/client/lib/sentinel/index.ts","lineNumber":1761,"sourceCode":"      try {\n        const masterData = await client.sentinel.sentinelMaster(this.options.name);\n\n        const master = parseNode(masterData);\n        if (master === undefined) {\n          continue;\n        }\n\n        return master;\n      } finally {\n        client.destroy();\n      }\n    }\n\n    if (connected) {\n      throw new Error(\"Master Node Not Enumerated\");\n    }\n\n    throw new Error(\"couldn't connect to any sentinels\");\n  }\n\n  async getMasterClient() {\n    const master = await this.getMasterNode();\n    const socket = getMappedNode(master.host, master.port, this.options.nodeAddressMap);\n    return RedisClient.create({\n      ...this.options.nodeClientOptions,\n      socket: {\n        ...this.options.nodeClientOptions?.socket,\n        host: socket.host,\n        port: socket.port\n      }\n    });\n  }\n\n  async getReplicaNodes() {\n    let connected = false;\n","sourceCodeStart":1743,"sourceCodeEnd":1779,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/sentinel/index.ts#L1743-L1779","documentation":"The companion of [88]: in `getMasterNode()`, if the loop never set `connected = true` (no sentinel could be reached at all), the method throws 'couldn't connect to any sentinels'. It is the pure connectivity-failure branch, distinct from the enumeration-failure branch.","triggerScenarios":"Calling `getMasterNode()` when every sentinel root node fails to connect. The `connected` flag stays false for the whole loop.","commonSituations":"All sentinels down; wrong host/port in rootNodes; auth failure (bad password) on every sentinel; network partition; TLS handshake failure.","solutions":["Make at least one sentinel reachable (host/port/DNS).","Correct `sentinelClientOptions` auth and TLS.","Add redundant sentinel seeds.","Check the sentinel process health and network path."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function getMasterWithRetry(sentinel: { getMasterNode(): Promise<unknown> }, attempts = 5) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await sentinel.getMasterNode(); }\n    catch (e) {\n      if (String(e).includes(\"couldn't connect to any sentinels\") && i < attempts - 1) {\n        await new Promise(r => setTimeout(r, 500 * 2 ** i)); continue;\n      }\n      throw e;\n    }\n  }\n}","preventionTips":["Keep multiple reachable sentinel seeds.","Verify sentinel auth/TLS once in CI against the real endpoints."],"tags":["sentinel","network","connectivity","master"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}