I cannot connect to Redis image from a Node image within Docker

First all was working great with default configuration until I hit one memory limit, then I needed to add a Redis configuration file (latest, 7.0). In this file bind is set to with default port, so I tried that. I also changed that to bind but I got the same error.

Now in for my environment variables I’m putting: redis//redis:6379 or redis:6379 so here is my configuration (docker-compose.yml):

version: '3.7'
    container_name: classified-ads
      - redis-service
      - 3000:3000
      context: ./
    # restart: unless-stopped
      - REDIS_URI=redis:6379
      - INSIDE_DOCKER=wahoo
  # our custom image 
      container_name: redis-service
        context: ./docker/redis/
      privileged: true
      command: sh -c "./init.sh"
        - '6379:6379'
        - ./host-db/redis-data:/data/redis:rw

The error I’m getting is bloated and is from my client which is ioredis but it is clearly a connection error. (ioredis wrapped with Fastify/redis, so it is a failed promise that is very verbose but not clearly indicative, but it’s 100% a connection error).

I checked Redis logs piped to Docker and it is running fine.

I found the solution. While the default redis:alpine image use configuration with protection_mode yes I was using a new configuration with protection_mode no. I also removed the bind 'address' all together.

And reconnected normally from other services with redis:port as usual.
all thanks to docker - Cannot connect to redis container in app but can ping to that container - Stack Overflow

1 Like