{"record":{"id":"613e7e3e972f6736","repo":"redis/jedis","slug":"can-not-get-master-addr-master-name-sentinel-613e7e","errorCode":null,"errorMessage":"Can not get master addr, master name: {}. Sentinel: {}.","messagePattern":"Can not get master addr, master name: (.+?)\\. Sentinel: (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/java/redis/clients/jedis/JedisSentinelPool.java","lineNumber":387,"sourceCode":"    public void run() {\n\n      running.set(true);\n\n      while (running.get()) {\n\n        try {\n          // double check that it is not being shutdown\n          if (!running.get()) {\n            break;\n          }\n          \n          final HostAndPort hostPort = new HostAndPort(host, port);\n          j = new Jedis(hostPort, sentinelClientConfig);\n\n          // code for active refresh\n          List<String> masterAddr = j.sentinelGetMasterAddrByName(masterName);\n          if (masterAddr == null || masterAddr.size() != 2) {\n            LOG.warn(\"Can not get master addr, master name: {}. Sentinel: {}.\", masterName,\n                hostPort);\n          } else {\n            initMaster(toHostAndPort(masterAddr));\n          }\n\n          j.subscribe(new JedisPubSub() {\n            @Override\n            public void onMessage(String channel, String message) {\n              LOG.debug(\"Sentinel {} published: {}.\", hostPort, message);\n\n              String[] switchMasterMsg = message.split(\" \");\n\n              if (switchMasterMsg.length > 3) {\n\n                if (masterName.equals(switchMasterMsg[0])) {\n                  initMaster(toHostAndPort(Arrays.asList(switchMasterMsg[3], switchMasterMsg[4])));\n                } else {\n                  LOG.debug(","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/JedisSentinelPool.java#L369-L405","documentation":"MasterListener is a background thread subscribing to Sentinel's +switch-master channel; before subscribing it actively refreshes the master address with sentinelGetMasterAddrByName and calls initMaster. If the response is null or not [host, port], it logs this warning (with a trailing period, distinguishing it from error 295) and skips initMaster — the thread keeps running and relies on the pub/sub for later updates.","triggerScenarios":"Inside MasterListener.run: a live Sentinel returns null or a malformed address list for masterName during the periodic active refresh — same root causes as the initSentinels variant (unknown master name, Sentinel not yet monitoring the master).","commonSituations":"Long-lived client whose Sentinel lost/re-added the monitored master; master name mismatch noticed only after startup; Sentinel restart wiped monitoring config (no `sentinel monitor` persisted via rewrite).","solutions":["Check `SENTINEL masters` on the Sentinel in the warning; re-add `sentinel monitor <name>` if it was lost (and persist with `SENTINEL RESET`/config rewrite).","Correct the masterName in the client config if it doesn't match the monitored name.","Confirm the Sentinel can still resolve the master (master up, Sentinel connectivity to it).","Restart the client after fixing Sentinel state so an initial refresh succeeds; pub/sub +switch-master will otherwise only fire on the next switch."],"exampleFix":"// on the Sentinel host, before relying on the client\n// before: (master missing)\n// after:\n// redis-cli -p 26379 SENTINEL MONITOR mymaster 127.0.0.1 6379 2\n// redis-cli -p 26379 SENTINEL SET mymaster down-after-milliseconds 5000","handlingStrategy":"retry","validationCode":"try (Jedis s = new Jedis(sentinelHost, 26379)) {\n  boolean known = s.sentinelMasters().stream().anyMatch(m -> masterName.equals(m.get(\"name\")));\n  if (!known) throw new IllegalStateException(\"Sentinel no longer monitors \" + masterName);\n}","typeGuard":null,"tryCatchPattern":"try { initMaster(addr); } catch (JedisException e) { log.warn(\"master refresh failed from sentinel {}:{}, waiting for +switch-master\", host, port, e); }","preventionTips":["Persist Sentinel monitoring config (sentinel rewrite) so restarts don't drop the master","Alert on `SENTINEL masters` losing the expected master name","Restart clients after Sentinel state is repaired so active refresh succeeds","Keep MasterListener threads alive — they self-heal via pub/sub once Sentinel recovers"],"tags":["redis","sentinel","failover","configuration"],"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"}