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

Opster Team

August-23, Version: 6.8-8.9

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.

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?