Please refer to: Redis Desktop Manager successfully linked, but Scrapy-redis was rejected, error code: 111

I ran a redis container with the following command:

docker run  --name redis_env --hostname redis \
            -p 6379:6379 \
            -v $PWD/DBVOL/redis/data:/data:rw \
            --privileged=true \
            -d redis redis-server

I successfully linked to the Redis server using Redis Desktop Manager locally, but when I built a distributed crawler using scrapy-redis according to the documentation, I got an error message rejecting the connection:

clipboard.png

my settings.py is configured as:

>>> import redis
>>> redis.connection("redis://localhost:6379/0")
Connection<host=redis://localhost:6379/0,port=6379,db=0>

what is the reason for this? How to solve? Please don"t hesitate to give us your advice, thank you!

Jun.16,2022

problem found. It is the ip problem of the container. The ip of the container is incorrect. Run:

docker inspect -f {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

get the ip of the container and fill in the link string. But I still don't understand, why? Can I successfully link my rdm by filling in 127.0.0.1 6379?


scrapy and redis run in different containers. 127.0.0.1 of redis and 127.0.0.1 of scrapy are not the same container or private network ip.
if you want to connect redis in the scrapy container, the configured ip should write either the ip of the redis container or the ip address of the host.

Menu