Jump to solution
Verify

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #1902 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -677,12 +677,19 @@ def _error_message(self, exception): # or just "message" if len(exception.args) == 1: - return f"Error connecting to {self.host}:{self.port}. {exception.args[0]}." + try: + return f"Error connecting to {self.host}:{self.port}. \
repro.py
connection_pool = ConnectionPool( connection_class=redis.connection.UnixDomainSocketConnection, max_connections = None, path=socket_path, "password": password, "socket_timeout": socket_timeout, "encoding": "utf-8", "encoding_errors": "strict", "decode_responses": True, "retry_on_timeout": False, ) rc = redis.Redis(connection_pool=connection_pool)
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: Do not use this fix if the connection class is not UnixDomainSocketConnection.\n\n

Why This Fix Works in Production

  • Trigger: AttributeError in UnixDomainSocketConnection starting v4.1.0
  • Mechanism: Fixes an AttributeError in UnixDomainSocketConnection that occurs when trying to ping an unreachable socket.
  • Why the fix works: Fixes an AttributeError in UnixDomainSocketConnection that occurs when trying to ping an unreachable socket. (first fixed release: 7.1.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.9 in real deployments (not just unit tests).
  • Surfaces as: AttributeError in UnixDomainSocketConnection starting v4.1.0

Proof / Evidence

  • GitHub issue: #1902
  • Fix PR: https://github.com/redis/redis-py/pull/1903
  • First fixed release: 7.1.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-07
  • Confidence: 0.95
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.56

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“**Version**: v4.1.0 **Platform**: python 3.9 **Description**: I have a ConnectionPool with connection_class=UnixDomainSocketConnection. In order to verify the socket is unreachable, we send a ping command and expect to get a ConnectionError”
Issue thread · issue description · source

Failure Signature (Search String)

  • AttributeError in UnixDomainSocketConnection starting v4.1.0

Error Message

Stack trace
error.txt
Error Message ------------- AttributeError in UnixDomainSocketConnection starting v4.1.0

Minimal Reproduction

repro.py
connection_pool = ConnectionPool( connection_class=redis.connection.UnixDomainSocketConnection, max_connections = None, path=socket_path, "password": password, "socket_timeout": socket_timeout, "encoding": "utf-8", "encoding_errors": "strict", "decode_responses": True, "retry_on_timeout": False, ) rc = redis.Redis(connection_pool=connection_pool)

Environment

  • Python: 3.9

What Broke

Users receive an AttributeError instead of a ConnectionError when pinging an unreachable socket.

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install redis==7.1.0

When NOT to use: Do not use this fix if the connection class is not UnixDomainSocketConnection.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/redis/redis-py/pull/1903

First fixed release: 7.1.0

Last verified: 2026-02-07. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if the connection class is not UnixDomainSocketConnection.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
  • Add a long-running test that repeats the failing call path and asserts stable memory.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
7.1.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.