redis cluster_error ai_generated true

MOVED 3999 127.0.0.1:7002

ID: redis/moved-ask-redirect

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7 active

Root Cause

Redis Cluster redirecting commands to the correct node. Client sent command to a node that does not own the target hash slot.

generic

Workarounds

  1. 95% success Use a cluster-aware client library
    redis-py: RedisCluster(host='...', port=7000); Jedis: JedisCluster; ioredis: new Cluster([{host, port}])

    Sources: https://redis.io/docs/latest/operate/oss_and_stack/management/

  2. 88% success Handle MOVED by updating the slot-to-node mapping in the client
    Cluster-aware clients do this automatically; raw clients must parse MOVED and reconnect to the target node
  3. 82% success Handle ASK by sending ASKING command followed by the original command to the target node
    ASK means slot is migrating; send ASKING + command to target node (temporary redirect, unlike MOVED)

Dead Ends

Common approaches that don't work:

  1. Retry the command on the same node hoping the slot migrates back 85% fail

    MOVED is permanent; the slot belongs to a different node. Retrying on the same node always fails.

  2. Connect to a single cluster node and ignore redirects 80% fail

    Single-node connection misses all keys not in that node's slots; most operations fail