{"record":{"id":"50824d76d7444647","repo":"redis/jedis","slug":"can-not-get-master-address-sentinel","errorCode":null,"errorMessage":"Can not get master {} address. Sentinel: {}.","messagePattern":"Can not get master (.+?) address\\. Sentinel: (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/java/redis/clients/jedis/providers/SentineledConnectionProvider.java","lineNumber":345,"sourceCode":"\n    @Override\n    public void run() {\n\n      running.set(true);\n\n      while (running.get()) {\n        try {\n          // double check that it is not being shutdown\n          if (!running.get()) {\n            break;\n          }\n\n          sentinelJedis = sentinelConnectionFactory.createConnection(node, sentinelClientConfig);\n\n          // code for active refresh\n          List<String> masterAddr = sentinelJedis.sentinelGetMasterAddrByName(masterName);\n          if (masterAddr == null || masterAddr.size() != 2) {\n            LOG.warn(\"Can not get master {} address. Sentinel: {}.\", masterName, node);\n          } else {\n            initMaster(toHostAndPort(masterAddr));\n          }\n\n          sentinelJedis.subscribe(new JedisPubSub() {\n            @Override\n            public void onSubscribe(String channel, int subscribedChannels) {\n              // Successfully subscribed - reset attempt counter\n              subscribeAttempt = 0;\n              LOG.debug(\"Successfully subscribed to {} on Sentinel {}. Reset attempt counter.\",\n                channel, node);\n            }\n\n            @Override\n            public void onMessage(String channel, String message) {\n              LOG.debug(\"Sentinel {} published: {}.\", node, message);\n\n              String[] switchMasterMsg = message.split(\" \");","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/providers/SentineledConnectionProvider.java#L327-L363","documentation":"In the SentineledConnectionProvider's active master-refresh thread (the subscribe/refresh loop's run method), the provider polls a Sentinel for the current master address via sentinelGetMasterAddrByName. If the answer is null or does not contain exactly two elements (host and port), it logs this warning and skips the initMaster update for that cycle, then continues to the Sentinel's pub/sub subscription. It means this particular Sentinel could not report the master at that moment.","triggerScenarios":"Periodic active refresh hits a Sentinel whose sentinelGetMasterAddrByName(masterName) returns null or a list of size != 2 — e.g. the Sentinel is still doing failover discovery, the master name is unknown to that Sentinel, or the Sentinel is in a transient error state.","commonSituations":"Right after a failover when the Sentinel has not yet re-published the new master; one Sentinel in the pool was added later and never configured to monitor the master; transient network/timeout causing an incomplete answer; master removed on the Sentinel side while the client keeps refreshing.","solutions":["Confirm with 'SENTINEL get-master-addr-by-name <masterName>' that the Sentinel knows the master; fix the master name or 'SENTINEL monitor' config if not.","Treat single occurrences as transient failover noise; only act if the warning repeats every refresh cycle.","Ensure all configured Sentinels monitor the same master name and quorum is met so failovers complete quickly.","Check Sentinel logs during failover to confirm it re-discovers the master and resumes answering.","Verify the master still exists (not removed via SENTINEL REMOVE) in your Sentinel topology."],"exampleFix":"// before\n// sentinel added to client list but never configured to monitor the master\n// after (on the Sentinel)\n// SENTINEL monitor mymaster 10.0.0.5 6379 2","handlingStrategy":"retry","validationCode":"// before enabling active refresh, confirm every configured Sentinel knows the master\nsentinels.forEach(s -> {\n  try (Jedis j = new Jedis(host(s), port(s))) {\n    if (j.sentinelGetMasterAddrByName(masterName) == null)\n      log.error(\"Sentinel {} does not monitor master {}\", s, masterName);\n  }\n});","typeGuard":null,"tryCatchPattern":"// the refresh loop already skips and continues on a bad answer; wrap your own failover listeners so a missed refresh triggers a re-check:\nscheduler.scheduleWithFixedDelay(() -> {\n  try (Jedis j = new Jedis(sentinelHost, sentinelPort)) {\n    List<String> addr = j.sentinelGetMasterAddrByName(masterName);\n    if (addr != null && addr.size() == 2) verifyClientMaster(addr.get(0), Integer.parseInt(addr.get(1)));\n  } catch (JedisException e) { /* next cycle retries */ }\n}, 0, 5, TimeUnit.SECONDS);","preventionTips":["Configure every Sentinel in the client list with 'SENTINEL monitor <name> ...' — no half-configured Sentinels.","Allow quorum-based failover to complete; single warnings right after failover are transient and self-healing.","Keep the pub/sub + switch-master channel subscribed (the provider does this) so master changes are pushed, not just polled.","Alert only on sustained warnings across consecutive refresh cycles, not isolated occurrences."],"tags":["redis-sentinel","master-refresh","failover","high-availability","polling"],"backgroundTag":"empty-result-set","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"}