# Org.elasticsearch.action.UnavailableShardsException

**URL:** <https://discuss.elastic.co/t/org-elasticsearch-action-unavailableshardsexception/7267>\
**Category:** Elasticsearch\
**Created:** [April 9, 2012, 9:02am UTC](https://discuss.elastic.co/t/org-elasticsearch-action-unavailableshardsexception/7267 "2012-04-09T09:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnesky](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@johnesky](https://discuss.elastic.co/u/johnesky)\
**Post date:** [April 9, 2012, 9:02am UTC](https://discuss.elastic.co/t/org-elasticsearch-action-unavailableshardsexception/7267/1 "2012-04-09T09:02:42Z")

</div>

I am trying to index a document from the Java API but I keep getting UnavailableShardsException. Please I need help. I don't know what it is I am not doing right. I have the source code and exception below. I am a newbie to Elasticsearch and please I'd appreciate anybody's help.

SOURCE CODE:  
ImmutableSettings.Builder settings =  
ImmutableSettings.settingsBuilder();  
settings.put("node.client", false);  
settings.put("node.data", false);  
settings.put("node.name", "Todd, Mark");  
settings.put("cluster.name", "elasticsearch");  
settings.put("network.host", "192.168.2.9");  
settings.put("network.bindHost", "192.168.2.9");  
settings.put("network.publishHost", "192.168.2.9");  
settings.put("index.number\_of\_shards", 5);  
settings.put("index.number\_of\_replicas", 1);  
settings.build();  
Node node = NodeBuilder.nodeBuilder().settings(settings).node();

IndexResponse response = client.prepareIndex("twitter", "tweet", "1")  
.setSource(jsonBuilder()  
.startObject()  
.field("user", "Joke")  
.field("postDate", new Date())  
.field("message", "trying out Elastic Search")  
.endObject()  
)  
.execute()  
.actionGet();

EXCEPTION:

org.elasticsearch.client.node.NodeClusterAdminClient@711b50a1  
Exception in thread "main" org.elasticsearch.action.UnavailableShardsException: [twitter][2] [2] shardIt, [0] active : Timeout waiting for [1m], request: index {[twitter][tweet][1], source[{"user":"Joke","postDate":"2012-04-09T08:55:58.030Z","message":"trying out Elastic Search"}]}  
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$4.onTimeout(TransportShardReplicationOperationAction.java:401)  
at org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:269)  
at org.elasticsearch.timer.TimerService$ThreadedTimerTask$1.run(TimerService.java:113)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
Java Result: 1

---

<div class="post-metadata">

**Author:** ![johnesky](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@johnesky](https://discuss.elastic.co/u/johnesky)\
**Post date:** [April 10, 2012, 6:14am UTC](https://discuss.elastic.co/t/org-elasticsearch-action-unavailableshardsexception/7267/2 "2012-04-10T06:14:51Z")

</div>

I finally got it solved...WHAT A RELIEF!

---

<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 6, 2017, 3:33am UTC](https://discuss.elastic.co/t/org-elasticsearch-action-unavailableshardsexception/7267/3 "2017-07-06T03:33:06Z")

</div>


