redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Cannot assign requested address

DrewLearns

Any ideas why I get a connection error when trying to run a redis command from one container to another? I'm trying to run an old python 2.7 lambda locally in order to test before upgrading to 3.8.10 I'm running a script that builds and links redisdb container with my_app container:

docker build . -t my_app:latest
docker pull redis:3.2.4-alpine && \
docker run --name=redisdb -d  redis:3.2.4-alpine redis-server
docker run \
    --rm -t -i -d \
    --link redisdb:redis \
    -h redis -p 6379 \
    -e CONFIG_FILE=local_config.yaml \
    my_app

I am running a python script on my_app with the following commands:

r = redis.Redis()
r.mset({"Bahamas": "Nassau"})
print(r.get("Bahamas"))

I've also tried the top suggestion here: Error 99 connecting to localhost:6379. Cannot assign requested address and passed r = redis.Redis(host='localhost', port=6379, decode_responses=True) with the same results.

Every time I try to run that python script in the my_app container, I get:

redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Cannot assign requested address.

When I run the containers and then check docker ps I get this:

$ docker ps
CONTAINER ID   IMAGE                          COMMAND                  CREATED              STATUS              PORTS                     NAMES
76aea9308821   mar-atlas-readings-processor   "python2"                About a minute ago   Up About a minute   0.0.0.0:64098->6379/tcp   mar-atlas-readings-processor
f313113341de   redis:3.2.4-alpine             "docker-entrypoint.s…"   About a minute ago   Up About a minute   6379/tcp                  redisdb

This shows the correct port connections.

artran

Your python app is trying to talk to Redis on localhost but the Redis container is on a different localhost.

You should be able to use the link configured in the docker run ... command, i.e redisdb, for the host option.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

socket.error:[errno 99] cannot assign requested address and namespace in python

RedisInsight on Docker and Redis on Docker: Could not connect: Error 99 connecting to localhost:6379. Cannot assign requested address

redis.exceptions.ConnectionError: Error -2 connecting to localhost:6379. Name or service not known

Flask, cannot assign requested address

Failed to listen on localhost:8000 (reason: Cannot assign requested address)

Cannot connect to redis://localhost:6379/0: Error 99 connecting to localhost:6379. Cannot assign requested address

Python - socket.error: Cannot assign requested address

rails + docker + sidekiq + Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)

GiLab CI - Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379

OSError: [Errno 99] Cannot assign requested address

HTTPServer: "Cannot assign requested address" on localhost vs 127.0.0.1

Server binding results in error "Cannot assign requested address"?

socket.error:[errno 99] cannot assign requested address : flask and python

Using Resque-Scheduler with Docker-Compose - Error connecting to Redis on localhost:6379

Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'

CentOS8 nginx: [emerg] bind() failed (99: Cannot assign requested address)

Docker + django_extensions + jupyter: OSError: [Errno 99] Cannot assign requested address

ssh_init: Network error: Cannot assign requested address

Postgresql connection with gorm dial error cannot assign requested address

Bind error (99): Cannot assign requested address

traceroute have error bind: Cannot assign requested address

Mesos bind error : Cannot assign requested address [99]

Raspberry Pi TCP socket - [Errno 99] Cannot assign requested address

zmq.error.ZMQError: Cannot assign requested address

PHP - memcache randomly fails with - Cannot assign requested address (99)

Nginx on Kubernetes (99: Cannot assign requested address)

Docker Cannot assign requested address

Errno 99 - Cannot assign requested address

Error -2 connecting to redis://redis:6379:6379. Name or service not known