﻿---
title: Diagnose unassigned shards
description: There are multiple reasons why shards might get unassigned, ranging from misconfigured allocation settings to lack of disk space. In order to diagnose...
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4067/troubleshoot/elasticsearch/diagnose-unassigned-shards
products:
  - Elasticsearch
---

# Diagnose unassigned shards
<admonition title="Simplify monitoring with AutoOps">
  Use AutoOps in your Elastic Cloud Hosted, ECE, ECK, or self-managed deployments.AutoOps is a monitoring tool that simplifies cluster management through performance recommendations, resource utilization visibility, and real-time issue detection with resolution paths. For more information, refer to [AutoOps](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4067/deploy-manage/monitor/autoops).
</admonition>

There are multiple reasons why shards might get unassigned, ranging from misconfigured allocation settings to lack of disk space.
In order to diagnose the unassigned shards in your deployment use the following steps:
<tab-set>
  <tab-item title="Elastic Cloud Hosted">
    In order to diagnose the unassigned shards, follow the next steps:**Use Kibana**
    1. Log in to the [Elastic Cloud console](https://cloud.elastic.co?page=docs&placement=docs-body).
    2. On the **Hosted deployments** panel, click the name of your deployment.
       <note>
       If the name of your deployment is disabled your Kibana instances might be unhealthy, in which case contact [Elastic Support](https://support.elastic.co). If your deployment doesn’t include Kibana, all you need to do is [enable it first](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4067/deploy-manage/deploy/elastic-cloud/access-kibana).
       </note>
    3. Open your deployment’s side navigation menu (placed under the Elastic logo in the upper left corner) and go to **Dev Tools > Console**.
       ![](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/4067/troubleshoot/images/elasticsearch-reference-kibana-console.png)

    1. View the unassigned shards using the [cat shards API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-shards).
       ```json
       ```
       The response will look like this:
       ```json
       [
         {
           "index": "my-index-000001",
           "shard": "0",
           "prirep": "p",
           "state": "UNASSIGNED",
           "node": null,
           "unassigned.reason": "INDEX_CREATED"
         }
       ]
       ```
       Unassigned shards have a `state` of `UNASSIGNED`. The `prirep` value is `p` for primary shards and `r` for replicas.
       The index in the example has a primary shard unassigned.
    2. To understand why an unassigned shard is not being assigned and what action you must take to allow Elasticsearch to assign it, use the [cluster allocation explanation API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-allocation-explain).
       ```json

       {
         "index": "my-index-000001", <1>
         "shard": 0, <2>
         "primary": true <3>
       }
       ```
       The response will look like this:
       ```json
       {
         "index" : "my-index-000001",
         "shard" : 0,
         "primary" : true,
         "current_state" : "unassigned",                 
         "unassigned_info" : {
           "reason" : "INDEX_CREATED",                   
           "at" : "2022-01-04T18:08:16.600Z",
           "last_allocation_status" : "no"
         },
         "can_allocate" : "no",                          
         "allocate_explanation" : "Elasticsearch isn't allowed to allocate this shard to any of the nodes in the cluster. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
         "node_allocation_decisions" : [
           {
             "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
             "node_name" : "node-0",
             "transport_address" : "127.0.0.1:9401",
             "roles": ["data_content", "data_hot"],
             "node_attributes" : {},
             "node_decision" : "no",                     
             "weight_ranking" : 1,
             "deciders" : [
               {
                 "decider" : "filter",                   
                 "decision" : "NO",
                 "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"  
               }
             ]
           }
         ]
       }
       ```
    3. The explanation in our case indicates the index allocation configurations are not correct. To review your allocation settings, use the [get index settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-settings) and [cluster get settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-get-settings) APIs.
       ```json
       ```
    4. Change the settings using the [update index settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-settings) and [cluster update settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings) APIs to the correct values in order to allow the index to be allocated.
    For more guidance on fixing the most common causes for unassinged shards follow [this guide](/elastic/docs-content/pull/4067/troubleshoot/elasticsearch/red-yellow-cluster-status#fix-red-yellow-cluster-status), see [these examples](https://www.elastic.co/docs/troubleshoot/elasticsearch/cluster-allocation-api-examples), or contact [Elastic Support](https://support.elastic.co).
  </tab-item>

  <tab-item title="Self-managed">
    In order to diagnose the unassigned shards follow the next steps:
    1. View the unassigned shards using the [cat shards API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-shards).
       ```json
       ```
       The response will look like this:
       ```json
       [
         {
           "index": "my-index-000001",
           "shard": "0",
           "prirep": "p",
           "state": "UNASSIGNED",
           "node": null,
           "unassigned.reason": "INDEX_CREATED"
         }
       ]
       ```
       Unassigned shards have a `state` of `UNASSIGNED`. The `prirep` value is `p` for primary shards and `r` for replicas.
       The index in the example has a primary shard unassigned.
    2. To understand why an unassigned shard is not being assigned and what action you must take to allow Elasticsearch to assign it, use the [cluster allocation explanation API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-allocation-explain).
       ```json

       {
         "index": "my-index-000001", <1>
         "shard": 0, <2>
         "primary": true <3>
       }
       ```
       The response will look like this:
       ```json
       {
         "index" : "my-index-000001",
         "shard" : 0,
         "primary" : true,
         "current_state" : "unassigned",                 
         "unassigned_info" : {
           "reason" : "INDEX_CREATED",                   
           "at" : "2022-01-04T18:08:16.600Z",
           "last_allocation_status" : "no"
         },
         "can_allocate" : "no",                          
         "allocate_explanation" : "Elasticsearch isn't allowed to allocate this shard to any of the nodes in the cluster. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
         "node_allocation_decisions" : [
           {
             "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
             "node_name" : "node-0",
             "transport_address" : "127.0.0.1:9401",
             "roles": ["data_content", "data_hot"]
             "node_attributes" : {},
             "node_decision" : "no",                     
             "weight_ranking" : 1,
             "deciders" : [
               {
                 "decider" : "filter",                   
                 "decision" : "NO",
                 "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"  
               }
             ]
           }
         ]
       }
       ```
    3. The explanation in our case indicates the index allocation configurations are not correct. To review your allocation settings, use the [get index settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-settings) and [cluster get settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-get-settings) APIs.
       ```json
       ```
    4. Change the settings using the [update index settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-settings) and [cluster update settings](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings) APIs to the correct values in order to allow the index to be allocated.
    For more guidance on fixing the most common causes for unassinged shards follow [this guide](/elastic/docs-content/pull/4067/troubleshoot/elasticsearch/red-yellow-cluster-status#fix-red-yellow-cluster-status), see [these examples](https://www.elastic.co/docs/troubleshoot/elasticsearch/cluster-allocation-api-examples), or contact [Elastic Support](https://support.elastic.co).
  </tab-item>
</tab-set>

Watch [this video](https://www.youtube.com/watch?v=v2mbeSd1vTQ) for a walkthrough of monitoring allocation health.

## Common issues

The following sections provide advice for resolving some of the common causes for unassigned shards.

### Conflicting settings

A primary shard might be unassigned due to conflicting settings.
View [this video](https://www.youtube.com/watch?v=5z3n2VgusLE) for a walkthrough of troubleshooting a node and index setting mismatch.

### Maximum number of retries exceeded

When Elasticsearch is unable to allocate a shard, it will attempt to retry allocation up to the maximum number of retries allowed.
After this, Elasticsearch will stop attempting to allocate the shard in order to prevent infinite retries which may impact cluster performance.
You can use an API to [reroute the cluster](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-reroute), which will allocate the shard if the issue preventing allocation has been resolved.

### No valid shard copy

If a shard is unassigned with an allocation status of `no_valid_shard_copy`, you should make sure that all nodes are in the cluster. If all the nodes containing in-sync copies of a shard are lost, then you can recover the data for the shard.
View [this video](https://www.youtube.com/watch?v=6OAg9IyXFO4) for a walkthrough of troubleshooting `no_valid_shard_copy`.