title: Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool;
body: <p>My Spring boot app hosted in AKS Azure, while hitting the redis cache in Azure, getting <code>Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to my_cache.redis.cache.windows.net/&lt;unresolved&gt;:6380</code></p>
  <p><strong>relevant configurations in yml:</strong></p>
  <pre><code>spring:
    cache:
      type: redis
    redis:
      host: my_cache.redis.cache.windows.net
      ssl: true
      port: 6380
      password: ${REDIS_PRIMARY_ACCESS_KEY}
  </code></pre>
  <p><strong>relevant codes</strong></p>
  <pre><code>@Configuration
  public class RedisConfig {
  
    private RedisProperties redisProperties;
    
    @Autowired
    public RedisConfig(RedisProperties redisProperties) {
      super();
      this.redisProperties = redisProperties;
    }
  
    @Bean
    @Primary
    public ReactiveRedisConnectionFactory reactiveRedisConnectionFactory(RedisConfiguration defaultRedisConfig) {
        LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder().commandTimeout(Duration.ofMillis(10000))
                .useSsl().build();
        return new LettuceConnectionFactory(defaultRedisConfig, clientConfig);
    }
  
    @Bean
    public RedisConfiguration defaultRedisConfig() {
        RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
        config.setHostName(redisProperties.getHost());
        config.setPassword(RedisPassword.of(redisProperties.getPassword()));
        config.setPort(redisProperties.getPort());
        return config;
    }
  
  @Configuration
  @ConfigurationProperties(prefix = &quot;spring.redis&quot;)
  public class RedisProperties {
  
    private String host;
    private String password;
    private int port;
    
    public String getHost() {
      return host;
    }
    public void setHost(String host) {
      this.host = host;
    }
    public String getPassword() {
      return password;
    }
    public void setPassword(String password) {
      this.password = password;
    }
    public int getPort() {
      return port;
    }
    public void setPort(int port) {
      this.port = port;
    }
    
  }
  
  @Service
  @CacheConfig(cacheNames = {&quot;TestPolicy&quot;})
  public class RedisServiceImpl implements RedisService {
  
    private Logger log = LoggerFactory.getLogger(RedisServiceImpl.class);
    
    @Override
    @Cacheable(key = &quot;#policyNo&quot;)
    public PolicyTest getPolicyByNo(String policyNo) {
      log.info(&quot;RedisServiceImpl::getPolicyByNo() fetching TestPolicy from service ...&quot;);
      return new PolicyTest(&quot;123&quot;, &quot;1001&quot;, &quot;200578&quot;);
    }
  
  }
  </code></pre>
  <p>And yes, I've referred similar threads like <a href="https://stackoverflow.com/questions/63572259/unable-to-connect-to-redisnested-exception-is-io-lettuce-core-redisconnectionex">Unable to connect to Redis;nested exception is io.lettuce.core.RedisConnectionException using RedisTempalte</a> without any luck.</p>
  <ul>
  <li>is something wrong with the configuration?</li>
  <li>Could it be some security issue ?  pinging the redis host from java using <code>InetAddress.getByName(&quot;my_cache.redis.cache.windows.net&quot;).isReachable(5000);</code> and using <code>Socket s = new Socket(&quot;my_cache.redis.cache.windows.net&quot;, 6380)</code> is successfull.</li>
  </ul>
  <p>Thanks,</p>