Failed to prepare shard for recovery – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when Elasticsearch is unable to prepare a shard for recovery due to issues like insufficient disk space, network connectivity problems, or corrupted data. To resolve this, you can try freeing up disk space, checking network connectivity, or restoring the shard from a backup. If the shard is corrupted and there’s no backup, you may need to delete and recreate it. Also, ensure that the Elasticsearch cluster health is green and all nodes are functioning properly.

This guide will help you check for common problems that cause the log ” failed to prepare shard for recovery ” 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 “failed to prepare shard for recovery” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 final var cleanupOnly = ActionListener.notifyOnce(ActionListener.runBefore(ActionListener.noop().delegateResponse((l; e) -> {
 // this will be logged as warning later on...
 logger.trace("unexpected error while preparing shard for peer recovery; failing recovery"; e);
 new RecoveryFailedException(recoveryTarget.state(); "failed to prepare shard for recovery"; e);
 }); onCompletion::close));  if (indexShard.routingEntry().isPromotableToPrimary() == false) {


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?