Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2203

Container API cannot connect to container Redis: RedisConnectionFailureException: Unable to connect to Redis

$
0
0

I'm trying to connect to a Redis database through a Java application, but I'm getting the following error:

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
Caused by: java.net.ConnectException: Connection refused

This is my docker-compose:

version: "2.1"services:  api:    container_name: api    image: xpto/game    build:      context: .    restart: on-failure    environment:      SPRING_PROFILES_ACTIVE: docker      APP_DATABASE_HOST: redis      APP_DATABASE_PORT: 6379    ports:      - "8080:8080"    networks:      - web    depends_on:      - redis  redis:    container_name: redis    hostname: redis    image: redis:latest    restart: on-failure    ports:      - 6379:6379    networks:      - web

And this is my application.properties:

spring.cache.redis.host=${APP_DATABASE_HOST}spring.cache.redis.port=${APP_DATABASE_PORT}

I also set up a container with a Redis client (Redis Commander) and managed to connect successfully. Only the container running the Java API doesn't work


Viewing all articles
Browse latest Browse all 2203

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>