dark_matter88
dark_matter88

Reputation: 377

Getting Name of service not known with Redis [Error -2]

When I run my docker container with redis locally using 8001 port everything is alright, but when I run it on 8080 port for debugging I get redis.exceptions.ConnectionError: Error -2 connecting to redis:63791. Name or service not known.

My docker yml file:

redis:
image: redis:latest
command: redis-server /etc/redis-stable/redis/redis.conf
volumes:
  - ./redis/:/etc/redis-stable/redis/
ports:
  - "63791:6379"

I checked through redis-cli and I get 127.0.0.1:6379>. Maybe the problem is somewhere deeper. I tried docker inspect redis and it included only 6379 as exposed ports. Maybe I should add 63971?

Upvotes: 1

Views: 2116

Answers (1)

Cassie
Cassie

Reputation: 3099

The essence of the problem is that you trying to connect to 8081 port from your container, and your service name is not resolved as a hostname. If you want to connect to the local machine, you need to change some environment variables or any other configs you have for that

Upvotes: 1

Related Questions