database
protocol_error
ai_generated
true
redis.exceptions.ResponseError: MOVED 12345 192.168.1.10:6379
ID: database/redis-cluster-moved-redirect
90%Fix Rate
85%Confidence
1Evidence
2024-01-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Redis 6.2 | active | — | — | — |
| Redis 7.0 | active | — | — | — |
| Redis 7.2 | active | — | — | — |
Root Cause
A Redis cluster client sent a command to the wrong node; the cluster slot is owned by a different node, requiring a redirect.
generic中文
Redis集群客户端将命令发送到了错误的节点;该集群槽位由另一个节点拥有,需要重定向。
Official Documentation
https://redis.io/docs/latest/operate/oss_and_stack/management/scaling/Workarounds
-
95% success Use a Redis cluster-aware client (e.g., redis-py-cluster) that automatically follows MOVED redirects: from rediscluster import RedisCluster; rc = RedisCluster(startup_nodes=[{'host':'192.168.1.10','port':6379}], decode_responses=True)
Use a Redis cluster-aware client (e.g., redis-py-cluster) that automatically follows MOVED redirects: from rediscluster import RedisCluster; rc = RedisCluster(startup_nodes=[{'host':'192.168.1.10','port':6379}], decode_responses=True) -
90% success Execute the command on the node specified in the MOVED error: redis-cli -h 192.168.1.10 -p 6379 GET mykey
Execute the command on the node specified in the MOVED error: redis-cli -h 192.168.1.10 -p 6379 GET mykey
-
85% success Refresh the cluster slots map in the client: rc.cluster_slots = rc.cluster_slots() to force a re-fetch of slot assignments.
Refresh the cluster slots map in the client: rc.cluster_slots = rc.cluster_slots() to force a re-fetch of slot assignments.
中文步骤
Use a Redis cluster-aware client (e.g., redis-py-cluster) that automatically follows MOVED redirects: from rediscluster import RedisCluster; rc = RedisCluster(startup_nodes=[{'host':'192.168.1.10','port':6379}], decode_responses=True)Execute the command on the node specified in the MOVED error: redis-cli -h 192.168.1.10 -p 6379 GET mykey
Refresh the cluster slots map in the client: rc.cluster_slots = rc.cluster_slots() to force a re-fetch of slot assignments.
Dead Ends
Common approaches that don't work:
-
Ignore the MOVED error and retry the same node
100% fail
The cluster topology is static for that slot; retrying the same node will always fail because the slot is not hosted there.
-
Manually update the client's cluster slots map by hardcoding IP addresses
70% fail
Cluster nodes can change IPs or rebalance slots; hardcoding breaks when the cluster topology changes.