[Python] ConnectionError: SERVER_CLOSED_CONNECTION_ERROR when connecting to multiple Redis...

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect to multiple Redis hosts using Python's redis-py library. Here’s the code I am using:

    import redis

    self.redis_client = redis.Redis(
    host=self.host,
    port=int(self.port),
    username=self.username,
    password=self.password,
    decode_responses=True
    )
    print(self.redis_client.ping())


    This works perfectly for one of the hosts — I get a True response from ping().

    However, for other hosts, I get the following error:


    redis.exceptions.ConnectionError: Connection closed by server. (SERVER_CLOSED_CONNECTION_ERROR)
    ​

    Interestingly, I am able to see data from all these hosts using the RedisInsight app, so the credentials and connectivity seem correct.

    What I tried: Verified the host, port, username, and password (same as used in RedisInsight).

    Why am I able to connect to one Redis host successfully, but getting SERVER_CLOSED_CONNECTION_ERROR for others?

    Continue reading...

Compartilhe esta Página