Shard is closed and recovery was canceled reason reason – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when a shard in Elasticsearch is closed during a recovery process, which is then canceled. This could be due to a node leaving or joining the cluster, or due to manual intervention. To resolve this issue, you can try restarting the Elasticsearch node, or manually rerouting the shard using the cluster reroute API. If the problem persists, check the cluster health and ensure that there are no underlying issues with the nodes or network.

This guide will help you check for common problems that cause the log ” shard is closed and recovery was canceled reason [” + reason + “] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: shard, recovery, indices.

Log Context

Log “shard is closed and recovery was canceled reason [” + reason + “]” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 final Closeable releaseResources = () -> IOUtils.close(resources);
 try {
 cancellableThreads.setOnCancel((reason; beforeCancelEx) -> {
 final RuntimeException e;
 if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us
 e = new IndexShardClosedException(shard.shardId(); "shard is closed and recovery was canceled reason [" + reason + "]");
 } else {
 e = new CancellableThreads.ExecutionCancelledException("recovery was canceled reason [" + reason + "]");
 if (beforeCancelEx != null) {


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?