{"record":{"id":"09dcdc6a09576f24","repo":"redis/jedis","slug":"can-connect-to-sentinel-but-mastername-seems-to","errorCode":null,"errorMessage":"Can connect to sentinel, but <masterName> seems to be not monitored...","messagePattern":"Can connect to sentinel, but <masterName> seems to be not monitored\\.\\.\\.","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/JedisSentinelPool.java","lineNumber":282,"sourceCode":"          LOG.warn(\"Can not get master addr, master name: {}. Sentinel: {}\", masterName, sentinel);\n          continue;\n        }\n\n        master = toHostAndPort(masterAddr);\n        LOG.debug(\"Found Redis master at {}\", master);\n        break;\n      } catch (JedisException e) {\n        // resolves #1036, it should handle JedisException there's another chance\n        // of raising JedisDataException\n        LOG.warn(\n          \"Cannot get master address from sentinel running @ {}. Reason: {}. Trying next one.\", sentinel, e);\n      }\n    }\n\n    if (master == null) {\n      if (sentinelAvailable) {\n        // can connect to sentinel, but master name seems to not monitored\n        throw new JedisException(\"Can connect to sentinel, but \" + masterName\n            + \" seems to be not monitored...\");\n      } else {\n        throw new JedisConnectionException(\"All sentinels down, cannot determine where is \"\n            + masterName + \" master is running...\");\n      }\n    }\n\n    LOG.info(\"Redis master running at {}, starting Sentinel listeners...\", master);\n\n    for (HostAndPort sentinel : sentinels) {\n\n      MasterListener masterListener = new MasterListener(masterName, sentinel.getHost(), sentinel.getPort());\n      // whether MasterListener threads are alive or not, process can be stopped\n      masterListener.setDaemon(true);\n      masterListeners.add(masterListener);\n      masterListener.start();\n    }\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/JedisSentinelPool.java#L264-L300","documentation":"JedisSentinelPool.initSentinels() queries each configured sentinel for the current master address of masterName. If at least one sentinel was reachable (sentinelAvailable) but none returned a master entry, it concludes the master name is not monitored and throws JedisException(\"Can connect to sentinel, but <masterName> seems to be not monitored...\").","triggerScenarios":"Calling the JedisSentinelPool constructor with a masterName that no reachable sentinel is monitoring — SENTINEL get-master-addr-by-name returns null from every sentinel that answered.","commonSituations":"Typo in masterName (e.g. 'mymaster' vs 'master'); sentinels configured for a different master set than the client; sentinel monitoring was removed via SENTINEL REMOVE; pointing at the wrong sentinel port or host.","solutions":["Verify masterName with `redis-cli -p 26379 SENTINEL get-master-addr-by-name <masterName>`.","Run `SENTINEL masters` on the sentinel to list monitored names and fix the client's masterName string.","If monitoring is missing, add it: `SENTINEL MONITOR <name> <ip> <port> <quorum>`.","Confirm the client's sentinel host/port list points at the intended sentinel deployment."],"exampleFix":"// before\nSet<String> sentinels = ...;\nJedisSentinelPool pool = new JedisSentinelPool(\"mymaster1\", sentinels); // typo\n// after\nJedisSentinelPool pool = new JedisSentinelPool(\"mymaster\", sentinels); // matches SENTINEL masters output","handlingStrategy":"validation","validationCode":"try (Jedis s = new Jedis(sentinelHost, 26379)) {\n  List<String> addr = s.sentinelGetMasterAddrByName(masterName);\n  if (addr == null) throw new IllegalStateException(\"masterName not monitored: \" + masterName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  pool = new JedisSentinelPool(masterName, sentinels);\n} catch (JedisException e) {\n  if (e.getMessage().contains(\"seems to be not monitored\")) {\n    // fix masterName or add SENTINEL MONITOR, then retry\n  } else throw e;\n}","preventionTips":["Validate masterName against `SENTINEL masters` before constructing the pool.","Externalize masterName to config and verify it matches sentinel deployment.","Ensure client and sentinel point to the same logical deployment.","After `SENTINEL REMOVE`, re-add monitoring before connecting clients."],"tags":["sentinel","configuration","redis"],"backgroundTag":"resource-not-found","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}