ASK error

The key's hash slot is moving to another cluster node, and the key may already be there.

A Redis cluster returns this error while a hash slot is moving from one node to another, for example, while you reshard the cluster. The key you asked for isn't on the node you sent the command to, so it may already be on the new node. The error gives the slot number and the new node's address:

ASK 8000 127.0.0.1:6461

In client libraries

Client libraryException or error typeMessage
redis-py AskError <slot> <endpoint>:<port>
RedisCluster follows the redirect itself and raises this error only if it can't.
Jedis JedisAskDataException ASK <slot> <endpoint>:<port>
JedisCluster follows the redirect itself and raises this error only if it can't.
node-redis SimpleError
Test with err.message.startsWith('ASK')
ASK <slot> <endpoint>:<port>
createCluster follows the redirect itself, and throws MaxCommandRedirectionsError after 16 attempts by default.
Lettuce
The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()).
RedisCommandExecutionException ASK <slot> <endpoint>:<port>
RedisClusterClient follows the redirect itself, and raises this error after 5 redirects by default.
go-redis redis.Error
Test with redis.IsAskError(err)
ASK <slot> <endpoint>:<port>
ClusterClient follows the redirect itself, and returns this error after MaxRedirects attempts (3 by default).
ioredis ReplyError
Test with err.message.startsWith('ASK')
ASK <slot> <endpoint>:<port>
Predis Predis\Response\ServerException
Test with $e->getErrorType() === 'ASK'
ASK <slot> <endpoint>:<port>
redis-rb Redis::CommandError ASK <slot> <endpoint>:<port> (redis://<host>:<port>)
redis-rs
The sync and async APIs raise the same errors.
ErrorKind::Server(ServerErrorKind::Ask) Ask: <slot> <endpoint>:<port>

Example

During the move, the old node no longer has the key:

> GET user:{42}:cart
(error) ASK 8000 127.0.0.1:6461

How to fix it

  • Your client doesn't support clusters. Use a cluster client, which handles ASK errors for you, as it does MOVED errors. In redis-cli, add the -c option.
  • You handle redirects yourself. Send ASKING to the node in the error, and then send the command again to that node. Without ASKING, the new node replies with MOVED and points you back to the old node. Unlike with MOVED, don't update your map of the cluster. The slot still belongs to the old node until the move finishes, so send later commands to the old node first.

See ASK redirection in the cluster specification.

RATE THIS PAGE
Back to top ↑