dockerredisredisinsights

[Docker-compose]: Unable to connect to redis server


I am unable to connect to redis server from redis insight.

version: '3'

services:
  redis:
    image: redis:7-alpine
    restart: always
    ports:
    - "6379:6379"
  redis-insight:
    image: redis/redisinsight:latest
    restart: always
    ports:
    - "5540:5540"
    volumes:
    - redis-insight:/data

volumes:
   redis-insight:

I tried many variations (localhost, 127.0.0.1), but It does not work. Any idea ?

enter image description here


Solution

  • Redis Insight and Redis are both in Docker. You need to use the Docker network to connect them. So, use the server names instead of the host (i.e. your computer).

    In your case, that would mean your host should be redis and the port should be 6379.