Redis conenction refused

Hi, i'm trying to run redis server in docker behind traefik.

This is my redis docker-compose configuration

version: "3"

services:
  redis:
    image: redis:latest
    restart: always
    volumes:
      - redis_db:/data
      - ./redis.conf:/usr/local/etc/redis/redis.conf
    networks:
      - traefik-proxy
      - redis_db
    environment:
      - REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
    labels:
      - "traefik.enable=true"
      # routers
      - "traefik.tcp.routers.redis.rule=HostSNI(`*`)"
      - "traefik.tcp.routers.redis.entryPoints=redis"
      - "traefik.tcp.routers.redis.service=redis"
      # services (needed for TCP)
      - "traefik.tcp.services.redis.loadbalancer.server.port=6379"

volumes:
  redis_db:

networks:
  traefik-proxy:
    external: true
  redis_db:

Entrypoint for redis

  redis:
    address: ":6379"

This lines i changed in redis.conf

requirepass strong_password
bind * -::*

In admin page everything looks great

I'm trying to connect from my pc
redis-cli -h redis.example.com
redis-cli -h redis.example.com -a strong_password

I also tried to enable tls and change SNI name
redis-cli -u redis://redis.example.com:6379 --tls --sni redis.example.com

But always i can see only this:
Could not connect to Redis at redis.example.com:6379: Connection refused

I have A DNS record redis.example.com (if it's suddenly important)

I hope you can help me figure out what I'm doing wrong

You have a beautiful entrypoint for redis, I assume it’s from traefik.yml. You need to add providers.docker to static config to read the labels.

You can place all your config in compose, see simple Traefik example.

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

I have docker provider in traefik.yml. All other services works fine (gitlab, portainer, youtrack and etc.).

Share your full Traefik static and dynamic config, and docker-compose.yml if used.

i found error, i didnt expose port 6379 in traefik docker-compose, thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.