# Getting "UnavailableShardsException" sometimes only

**URL:** <https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063>\
**Category:** Elasticsearch\
**Created:** [May 3, 2016, 2:25pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063 "2016-05-03T14:25:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Samanth\_Kumar\_Redd](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@K\_Samanth\_Kumar\_Redd](https://discuss.elastic.co/u/K_Samanth_Kumar_Redd)\
**Post date:** [May 3, 2016, 2:25pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/1 "2016-05-03T14:25:28Z")

</div>

Hi,

I am creating elasticsearch index using java with elasticsearch-2.2.0 version. I am stuckup with an exception: "UnavailableShardsException"  
I am using BULK API to create my index. Some times the index is being created successfully, some times I am getting the above exception.

I am wondering why this exception is coming only sometimes. This is causing me a big problem.

Can anyone help me please?

Thanks & Regards,  
Samanth

---

<div class="post-metadata">

**Author:** ![K\_Samanth\_Kumar\_Redd](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@K\_Samanth\_Kumar\_Redd](https://discuss.elastic.co/u/K_Samanth_Kumar_Redd)\
**Post date:** [May 4, 2016, 6:48am UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/2 "2016-05-04T06:48:31Z")

</div>

Can anyone please respond?

Thanks,  
Samanth

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 4, 2016, 6:50am UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/3 "2016-05-04T06:50:06Z")

</div>

Please be patient when waiting for an answer to your questions. This is a community forum and as such it may take some time before someone replies to your question. Not everyone on the forum is an expert in every area so you may need to wait for someone who knows about the area you are asking about to come online and have the time to look into your problem.

Please see [https://www.elastic.co/community/codeofconduct](https://www.elastic.co/community/codeofconduct) for more details on our code of conduct (in particular the "be patient" section).

There are no SLAs on responses to questions posted on this forum, if you require help with an SLA on responses you should look into purchasing a subscription package that includes support with an SLA such as those offered by Elastic: [https://www.elastic.co/subscriptions](https://www.elastic.co/subscriptions)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2016, 7:14am UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/4 "2016-05-04T07:14:46Z")

</div>

Have you checked your ES logs at the time this happens?

---

<div class="post-metadata">

**Author:** ![K\_Samanth\_Kumar\_Redd](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@K\_Samanth\_Kumar\_Redd](https://discuss.elastic.co/u/K_Samanth_Kumar_Redd)\
**Post date:** [May 13, 2016, 12:48pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/5 "2016-05-13T12:48:38Z")

</div>

Thank You! I checked the logs but I am not able to understand the exact problem. Please find the log file content below:

> [2016-05-11 03:20:05,157][DEBUG][action.admin.indices.stats] [Crazy Eight] [indices:monitor/stats] failed to execute operation for shard [[enduser][3], node[g60DVR92SseMGM69vgbzXQ], [P], v[2], s[STARTED], a[id=Myk36WGeQ8S92exXvDcjcg]]  
> ElasticsearchException[failed to refresh store stats]; nested: AccessDeniedException[C:\elasticsearch-2.2.0\data\elasticsearch\nodes\0\indices\enduser\3\index\_c\_Lucene50\_0.tim];  
> at org.elasticsearch.index.store.Store$StoreStatsCache.refresh(Store.java:1534)  
> at org.elasticsearch.index.store.Store$StoreStatsCache.refresh(Store.java:1519)  
> at org.elasticsearch.common.util.SingleObjectCache.getOrRefresh(SingleObjectCache.java:55)  
> at org.elasticsearch.index.store.Store.stats(Store.java:293)  
> at org.elasticsearch.index.shard.IndexShard.storeStats(IndexShard.java:665)  
> at org.elasticsearch.action.admin.indices.stats.CommonStats.(CommonStats.java:134)  
> at org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction.shardOperation(TransportIndicesStatsAction.java:165)  
> at org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction.shardOperation(TransportIndicesStatsAction.java:47)  
> at org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction$BroadcastByNodeTransportRequestHandler.onShardOperation(TransportBroadcastByNodeAction.java:409)  
> at org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction$BroadcastByNodeTransportRequestHandler.messageReceived(TransportBroadcastByNodeAction.java:388)  
> at org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction$BroadcastByNodeTransportRequestHandler.messageReceived(TransportBroadcastByNodeAction.java:375)  
> at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:350)  
> at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
> at java.lang.Thread.run(Thread.java:745)  
> Caused by: java.nio.file.AccessDeniedException: C:\elasticsearch-2.2.0\data\elasticsearch\nodes\0\indices\enduser\3\index\_c\_Lucene50\_0.tim  
> at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)

> ... 15 more  
> [2016-05-11 03:46:25,196][INFO][cluster.metadata] [Crazy Eight] [enduser] creating index, cause [api], templates , shards [5]/[1], mappings   
> [2016-05-11 03:46:25,222][WARN][indices.cluster] [Crazy Eight] [[enduser][2]] marking and sending shard failed due to [failed recovery]  
> [enduser][[enduser][2]] IndexShardRecoveryException[failed to recovery from gateway]; nested: EngineCreationFailureException[failed to create engine]; nested: AccessDeniedException[C:\elasticsearch-2.2.0\data\elasticsearch\nodes\0\indices\enduser\2\translog];  
> at org.elasticsearch.index.shard.StoreRecoveryService.recoverFromStore(StoreRecoveryService.java:254)  
> at org.elasticsearch.index.shard.StoreRecoveryService.access$100(StoreRecoveryService.java:56)  
> at org.elasticsearch.index.shard.StoreRecoveryService$1.run(StoreRecoveryService.java:129)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
> at java.lang.Thread.run(Thread.java:745)  
> Caused by: [enduser][[enduser][2]] EngineCreationFailureException[failed to create engine]; nested: AccessDeniedException[C:\elasticsearch-2.2.0\data\elasticsearch\nodes\0\indices\enduser\2\translog];  
> at org.elasticsearch.index.engine.InternalEngine.(InternalEngine.java:156)  
> at org.elasticsearch.index.engine.InternalEngineFactory.newReadWriteEngine(InternalEngineFactory.java:25)  
> at org.elasticsearch.index.shard.IndexShard.newEngine(IndexShard.java:1450)  
> at org.elasticsearch.index.shard.IndexShard.createNewEngine(IndexShard.java:1434)  
> at org.elasticsearch.index.shard.IndexShard.internalPerformTranslogRecovery(IndexShard.java:925)  
> at org.elasticsearch.index.shard.IndexShard.performTranslogRecovery(IndexShard.java:897)  
> at org.elasticsearch.index.shard.StoreRecoveryService.recoverFromStore(StoreRecoveryService.java:245)  
> ... 5 more

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 13, 2016, 1:58pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/6 "2016-05-13T13:58:16Z")

</div>

> [@K\_Samanth\_Kumar\_Redd](#):
>
> AccessDeniedException[C:\elasticsearch-2.2.0\data\elasticsearch\nodes\0\indices\enduser\3\index\_c\_Lucene50\_0.tim];

Looks like filesystem permission issues.

---

<div class="post-metadata">

**Author:** ![K\_Samanth\_Kumar\_Redd](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@K\_Samanth\_Kumar\_Redd](https://discuss.elastic.co/u/K_Samanth_Kumar_Redd)\
**Post date:** [May 16, 2016, 5:25am UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/7 "2016-05-16T05:25:03Z")

</div>

I do not understand one thing that is: it is loading the data sometimes successfully, but it is failing sometimes. I am wondering how it is possible. I am using BATCH API to load the data.

**Client Side Exception:**

> [172]: index [enduser], type [enduser], id [AVS4BSH5OtU25o4f73iq], message [UnavailableShardsException[[enduser][3] primary shard is not active Timeout: [1m], request: [shard bulk {[enduser][3]}]]]

Is there any configuration that needs to be done?.

Thanks,  
Samanth

---

<div class="post-metadata">

**Author:** ![Ben\_Davis](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Ben\_Davis](https://discuss.elastic.co/u/Ben_Davis)\
**Post date:** [August 11, 2016, 3:26pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/8 "2016-08-11T15:26:42Z")

</div>

I'm seeing the same thing you are. An index will be fine for weeks and then one day we get access denied errors. Frustrating.

This post indicates it can be an issue on Windows where you open Explorer on a different machine and navigate to the network drive housing your ES data. I closed all my connections from other workstations to that network drive. Maybe it will work.

---

<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:** [July 5, 2017, 10:28pm UTC](https://discuss.elastic.co/t/getting-unavailableshardsexception-sometimes-only/49063/9 "2017-07-05T22:28:20Z")

</div>


