{"id":"b7fd85880e0e632d","repo":"redis/redis","slug":"asking-failed-s-n","errorCode":null,"errorMessage":"ASKING failed: %s\\n","messagePattern":"ASKING failed: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/redis-cli.c","lineNumber":1806,"sourceCode":"\n/* In cluster, if server replies ASK, we will redirect to a different node.\n * Before sending the real command, we need to send ASKING command first. */\nstatic int cliSendAsking(void) {\n    redisReply *reply;\n\n    config.cluster_send_asking = 0;\n    if (context == NULL) {\n        return REDIS_ERR;\n    }\n    reply = redisCommand(context,\"ASKING\");\n    if (reply == NULL) {\n        fprintf(stderr, \"\\nI/O error\\n\");\n        return REDIS_ERR;\n    }\n    int result = REDIS_OK;\n    if (reply->type == REDIS_REPLY_ERROR) {\n        result = REDIS_ERR;\n        fprintf(stderr,\"ASKING failed: %s\\n\",reply->str);\n    }\n    freeReplyObject(reply);\n    return result;\n}\n\nstatic void cliPrintContextError(void) {\n    if (context == NULL) return;\n    fprintf(stderr,\"Error: %s\\n\",context->errstr);\n}\n\nstatic int isInvalidateReply(redisReply *reply) {\n    return reply->type == REDIS_REPLY_PUSH && reply->elements == 2 &&\n        reply->element[0]->type == REDIS_REPLY_STRING &&\n        !strncmp(reply->element[0]->str, \"invalidate\", 10) &&\n        reply->element[1]->type == REDIS_REPLY_ARRAY;\n}\n\n/* Special display handler for RESP3 'invalidate' messages.","sourceCodeStart":1788,"sourceCodeEnd":1824,"githubUrl":"https://github.com/redis/redis/blob/3acc0c49cf5ad2af9425d333e62728342dd6159b/src/redis-cli.c#L1788-L1824","documentation":"Printed by cliSendAsking() when the ASKING command completes but the server returns a REDIS_REPLY_ERROR (reply->str holds the server's error message). Unlike the NULL case at line 1800, the command reached the server but the server rejected it — for example because the node is not configured as a cluster node, is still loading, or the client state is invalid for ASKING.","triggerScenarios":"A cluster redirect (ASK) targets a node that is not a cluster master, or the server replies with an error to ASKING such as 'ERR This instance has cluster support disabled' or a loading/role-related error.","commonSituations":"Pointing a cluster-mode redis-cli at a standalone (non-cluster) server; cluster topology changed (resharding/failover) so the redirect target no longer owns the slot; node still loading the dataset after restart; a misconfigured or partially-set-up cluster.","solutions":["Read the full error text after 'ASKING failed:' — it names the exact server-side reason.","Confirm you are connected to a real cluster node: `CLUSTER INFO` should show cluster_enabled:1.","Verify slot ownership and node roles with `CLUSTER NODES` / `CLUSTER SLOTS`.","If the node is loading, wait for it to finish and retry the command."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"/* Only issue ASKING inside a cluster and only after a real ASK redirect. */\nif (!in_cluster_mode) return REDIS_ERR;                /* not a cluster: ASKING is invalid */\nif (!pending_ask_redirect) return REDIS_ERR;           /* no ASK in flight: nothing to satisfy */","typeGuard":null,"tryCatchPattern":"redisReply *r = redisCommand(context, \"ASKING\");\nif (r == NULL) { redisReconnect(context); return REDIS_ERR; }      /* I/O error */\nif (r->type == REDIS_REPLY_ERROR) {                                 /* ASKING rejected */\n    freeReplyObject(r);\n    refreshClusterSlots();            /* topology moved: reload slot->node map */\n    return reissueOnOwner(original_cmd, slot);  /* fallback: run cmd on the real owner */\n}\nfreeReplyObject(r);","preventionTips":["Use a cluster-aware client that tracks MOVED/ASK redirects automatically rather than hand-rolling ASKING.","Refresh the cluster slot map on topology changes (MOVED to an unknown node) before issuing further commands.","Respect the ASK protocol exactly: ASKING then the command on the same connection, do not pin the redirect.","Treat ASKING errors as recoverable: fall back to a full slot-map reload instead of failing the request."],"tags":["cluster","asking","server-error","redis-cli"],"analyzedSha":"3acc0c49cf5ad2af9425d333e62728342dd6159b","analyzedAt":"2026-08-01T22:07:56.715Z","schemaVersion":2}