# Fix Unallocated Shards

**URL:** <https://discuss.elastic.co/t/fix-unallocated-shards/167948>\
**Category:** Elasticsearch\
**Created:** [February 12, 2019, 3:10am UTC](https://discuss.elastic.co/t/fix-unallocated-shards/167948 "2019-02-12T03:10:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![keeshqs](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@keeshqs](https://discuss.elastic.co/u/keeshqs)\
**Post date:** [February 12, 2019, 3:10am UTC](https://discuss.elastic.co/t/fix-unallocated-shards/167948/1 "2019-02-12T03:10:50Z")

</div>

Good day,

I was hoping you could help us with the issue that we are are consistently encountering in Elasticsearch. We are running a single cluster with a single node in the Production environment and the indices are failing due to unallocated shards.  
Our temporary fix was to close each failed index every time but this is not helping us at all because a few of these indices are only three weeks old.  
Appreciate your help. Thanks in advance.

**We have tried the following to resolve:**  
**1. Set replicas to 0**  
**2. Enable shard allocation**  
**2. re-route unallocated shards**  
curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{ "commands" :[{ "allocate" : { "index" : "test", "shard" : 0, "node": "aIiS2\_OQRdid6MjBvuXGMg", "allow\_primary": "true" }}]}' -H 'Content-Type: application/json

**3. Force re-allocation**  
curl -XPOST 'localhost:9200/\_cluster/reroute?pretty' -d '{  
"commands" : [ {  
"allocate\_stale\_primary" :  
{  
"index" : ".test", "shard" : 0,  
"node" : "aIiS2\_O",  
"accept\_data\_loss" : true  
}  
}  
]  
}' -H 'Content-Type: application/json'

**_Elasticsearch Health:_**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c492e397e9809cd8acd2500f989cb4b8561abbbf.png)

_ **Allocation log** _

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0e947260d57232f4c50f3b677adfefc7183c3a99.png)

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [February 12, 2019, 5:56am UTC](https://discuss.elastic.co/t/fix-unallocated-shards/167948/2 "2019-02-12T05:56:09Z")

</div>

From the screen dump you provide it seems the problem is that you've exceeded your file system's max open files value. Since every shard needs open file handles for its file segments you won't be able to get that shard assigned until Elasticsearch can open more file handles.

You will either have to increase the max open files setting, see [Configuring system settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html), or you can reduce the number of open shards in your cluster by using [Shrink](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html) or [Reindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html) APIs to to create indices with fewer shards.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 12, 2019, 6:01am UTC](https://discuss.elastic.co/t/fix-unallocated-shards/167948/3 "2019-03-12T06:01:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
