Skip to content

The connection is closed by Connection closed by server. #2974

Open
@yuerem

Description

@yuerem

Version:
redis-py 5.0.0
Redis 6.2.6
python 3.11

Description:
I am using Amazon ElastiCache for Redis. After the execution of the maintenance window for Amazon ElastiCache for Redis, exceptions such as

redis.exceptions.RedisClusterException: Redis Cluster cannot be connected. Please provide at least one reachable node: Timeout connecting to server

and

redis.exceptions.ConnectionError: Connection closed by server.

were thrown.

I suspect that the cause was the failure of name resolution because the node's IP was changed after the execution of the maintenance window. Does anyone know a good solution to this issue?

Currently, I have globally defined the client as follows and am using it in various functions.

r = RedisCluster(
    host='xxx',
    port='yyy',
    encoding="utf-8",
    decode_responses=True,
    )

def sample1():
   r.set('foo', 'bar')

def sample2():
    r.get('foo')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions