redis/redis-py · error · RedisError
SHUTDOWN seems to have failed.
Error message
SHUTDOWN seems to have failed.
What it means
Raised as a RedisError by shutdown after the command executes WITHOUT raising a ConnectionError. A successful SHUTDOWN kills the server, so the connection is always dropped and a ConnectionError is expected and caught (the method returns normally). If no ConnectionError occurred, the shutdown did not complete as expected, so a RedisError is raised.
Source
Thrown at redis/commands/core.py:2129
if save and nosave:
raise DataError("SHUTDOWN save and nosave cannot both be set")
args = ["SHUTDOWN"]
if save:
args.append("SAVE")
if nosave:
args.append("NOSAVE")
if now:
args.append("NOW")
if force:
args.append("FORCE")
if abort:
args.append("ABORT")
try:
self.execute_command(*args, **kwargs)
except ConnectionError:
# a ConnectionError here is expected
return
raise RedisError("SHUTDOWN seems to have failed.")
@overload
def slaveof(
self: SyncClientProtocol,
host: str | None = None,
port: int | None = None,
**kwargs,
) -> bool: ...
@overload
def slaveof(
self: AsyncClientProtocol,
host: str | None = None,
port: int | None = None,
**kwargs,
) -> Awaitable[bool]: ...
def slaveof(View on GitHub (pinned to da03cdc7e8)
Solutions
- Verify the Redis server actually shut down (e.g., check process or port).
- If behind a proxy, connect directly to the Redis node for SHUTDOWN.
- In test environments using a mock server, expect and handle this error or mock the ConnectionError.
Example fix
# before
r.shutdown() # raises RedisError in test/mock env
# after
try:
r.shutdown()
except RedisError:
# connection wasn't dropped — verify server state externally
pass Defensive patterns
Strategy: try-catch
Try / catch
from redis.exceptions import RedisError, ConnectionError
try:
r.shutdown()
except ConnectionError:
pass # expected — server is shutting down
except RedisError:
# shutdown did not behave as expected — investigate
log.warning('SHUTDOWN did not drop the connection') Prevention
- A successful SHUTDOWN always drops the connection; the absence of that error is the anomaly.
- When using proxies or mock servers, SHUTDOWN behavior may differ — connect directly for real shutdowns.
When it happens
Trigger: The server responded to SHUTDOWN without closing the connection (unexpected server behavior). A network proxy or connection pool intercepted and suppressed the disconnect. The server was configured to ignore SHUTDOWN (e.g., via rename-command).
Common situations: Running behind a proxy (Twemproxy, Envoy) that keeps the connection alive. Server version or config that doesn't actually shut down. Mock/fake Redis in tests that doesn't drop the connection.
Related errors
- SHUTDOWN save and nosave cannot both be set
- Connection closed by server.
- Buffer is closed.
- Connection closed by server.
- A {type(error).__name__} occurred while watching one or more
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/b088730f62001e01.json.
Report an issue: GitHub.