Not primary can t move to replica – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Before you dig into reading this guide, have you tried asking OpsGPT what this log means? You’ll receive a customized analysis of your log.

Try OpsGPT now for step-by-step guidance and tailored insights into your Elasticsearch operation.

Briefly, this error occurs when an operation is attempted on a replica shard while it’s still being treated as a primary shard. This could be due to a network partition or a node failure. To resolve this issue, you can try the following: 1) Restart the Elasticsearch node, which can help reset the shard states. 2) Use the reroute API to manually change the allocation of the shard. 3) Check the cluster health and ensure all nodes are properly connected. 4) If the issue persists, consider reindexing the data.

For a complete solution to your to your search operation, try for free AutoOps for Elasticsearch & OpenSearch . With AutoOps and Opster’s proactive support, you don’t have to worry about your search operation – we take charge of it. Get improved performance & stability with less hardware.

This guide will help you check for common problems that cause the log ” Not primary; can’t move to replica ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: routing, cluster.

Log Context

Log “Not primary; can’t move to replica” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 * @throws IllegalShardRoutingStateException if shard is already a replica
 public ShardRouting moveUnassignedFromPrimary() {
 assert state == ShardRoutingState.UNASSIGNED : "expected an unassigned shard " + this;
 if (primary == false) {
 throw new IllegalShardRoutingStateException(this; "Not primary; can't move to replica");
 return new ShardRouting(


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?

Get expert answers on Elasticsearch/OpenSearch