redis-py: redis exceptions Connection Error: Connection closed by server
Redis config file: redis_conf.txt
Here is an exception:
I run latest version of redis in container:
redis: image: redis:latest container_name: redis ports: - 6379:6379 volumes: - ./config/redis.conf:/redis.conf command: [ “redis-server”, “/redis.conf” ]
The application is written in Python ver 3.9
`import redis
pool = redis.ConnectionPool(host=‘localhost’, port=6379, db=0) r = redis.Redis(connection_pool=pool)
r.set(‘foo’, ‘bar’) value = r.get(‘foo’) print(value)`
As you see it is very basic. I had more complicated code that I tried to run at the beginning where I communicated with redis in multithread. Later this code caused a problem so that I am not able even to start with the above simple code no matter what I do: restart the computer, restart container, reinstall redis module. nothing helps I send commands in redis cli and it works. But python throws an exception:
Please help me stay with redis!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
I found the problem and it made me embarrassed. The bind IP connection definition was wrong, redis was bound to IP of local host instead of container IP. The second I changed it code started running properly.
On Mon, Jan 18, 2021 at 4:31 PM Robert Geislinger notifications@github.com wrote:
For those from google, maybe
--tlsflag (or rediss:// with double s) is missing from your redis-cli command.Hey @Alexander770 , I’m facing the same issue (I think), can you share the conf file you used?