redis/redis-py · error · DataError
SHUTDOWN save and nosave cannot both be set
Error message
SHUTDOWN save and nosave cannot both be set
What it means
Raised by shutdown when both save=True and nosave=True are passed simultaneously. These flags are contradictory — save forces a DB dump on shutdown, nosave suppresses it — so the client rejects the combination before sending anything to the server.
Source
Thrown at redis/commands/core.py:2112
force: bool = False,
abort: bool = False,
**kwargs,
) -> None:
"""Shutdown the Redis server. If Redis has persistence configured,
data will be flushed before shutdown.
It is possible to specify modifiers to alter the behavior of the command:
``save`` will force a DB saving operation even if no save points are configured.
``nosave`` will prevent a DB saving operation even if one or more save points
are configured.
``now`` skips waiting for lagging replicas, i.e. it bypasses the first step in
the shutdown sequence.
``force`` ignores any errors that would normally prevent the server from exiting
``abort`` cancels an ongoing shutdown and cannot be combined with other flags.
For more information, see https://redis.io/commands/shutdown
"""
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.")
View on GitHub (pinned to da03cdc7e8)
Solutions
- Set exactly one of save or nosave (or neither for server-default behavior).
- Guard dynamic flags: if save and nosave: raise in your own code before calling.
- Use save=True to force persistence, nosave=True to skip it; never both.
Example fix
# before r.shutdown(save=True, nosave=True) # after r.shutdown(save=True)
Defensive patterns
Strategy: validation
Validate before calling
if save and nosave:
raise ValueError('shutdown: save and nosave are mutually exclusive') Prevention
- Treat save and nosave as mutually exclusive shutdown modifiers.
- Validate config-derived flags before passing to shutdown.
When it happens
Trigger: Calling r.shutdown(save=True, nosave=True). Building shutdown args dynamically where both flags resolve True. Copy-pasting a config that set both as a 'cover all cases' pattern.
Common situations: Config file maps two independent booleans that both default True. Migration from a system where one flag was ignored. Defensive code that sets both flags 'just in case'.
Related errors
- CLIENT KILL type must be one of {client_types!r}
- CLIENT KILL skipme must be a bool
- CLIENT KILL <filter> <value> ... ... <filter> <value> must s
- CLIENT LIST _type must be one of {client_types!r}
- client_id must be a list
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/735d2f83d085e725.json.
Report an issue: GitHub.