# Java client unable to connect - ClusterBlockException

**URL:** https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244
**Category:** Elasticsearch
**Created:** [June 28, 2012, 12:57am UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244 "2012-06-28T00:57:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pnayak](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pnayak](https://discuss.elastic.co/u/pnayak)
#### Post date: [June 28, 2012, 12:57am UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244/1 "2012-06-28T00:57:55Z")

</div>

I'd appreciate any help/insight into this problem... Thanks in advance for  
your time and help!

My ElasticSearch setup uses a single shard with no replica. I am running  
on a Rackspace cloud server. The works fine on my local Mac ☹

index.number\_of\_shards: 1  
index.number\_of\_replicas: 0

No other changes in the config file.

My cluster state is green after starting es:

curl -XGET [http://localhost:9200/\_cluster/health](http://localhost:9200/_cluster/health)  
\*  
{"cluster\_name":"elasticsearch","status":"green","timed\_out":false,"number\_of\_nodes":1,"number\_of\_data\_nodes":1,"active\_primary\_shards":0,"active\_shards":0,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":0}  
\*

When I start my app server, which uses the following to get a client...

_Node node = nodeBuilder().client(true).node();_  
_client = node.client();_

I get the following exception when a search is sought to be executed:

ERROR [2012-06-28 00:37:34,229]  
com.yammer.dropwizard.jersey.LoggingExceptionMapper: Error handling a  
request: 8f94de3bc1f8f645! org.elasticsearch.cluster.block._ClusterBlockException:  
blocked by: [SERVICE\_UNAVAILABLE/1/state not recovered /  
initialized];[SERVICE\_UNAVAILABLE/2/no master];! at  
org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException_  
(ClusterBlocks.java:136)  
! at  
org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(ClusterBlocks.java:126)  
! at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.(TransportSearchTypeAction.java:108)  
! at  
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.(TransportSearchDfsQueryThenFetchAction.java:76)  
! at  
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.(TransportSearchDfsQueryThenFetchAction.java:65)  
! at  
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:62)  
! at  
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:52)  
! at  
org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)!  
at  
org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:106)  
! at  
org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:43)  
! at  
org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)  
! at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:83)  
! at  
org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:206)

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [June 28, 2012, 1:44am UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244/2 "2012-06-28T01:44:58Z")

</div>

This exception means that your client cannot find your server. If you are  
running elasticsearch and app server on different machines, they, probably,  
cannot find each other because of blocked multicast traffic. If this is the  
case, try switching to unicast discovery. If they are running on the same  
machine, it's possible that firewall is interfering with discovery.  
Multicast discovery is using group 224.2.2.4 and port 54328.  
After initial multicast broadcast nodes are communicating on ports  
9300-9400 (first node on machine is using 9300, next node is using 9301 and  
so on.)

On Wednesday, June 27, 2012 8:57:55 PM UTC-4, Prashant wrote:

> I'd appreciate any help/insight into this problem... Thanks in advance  
> for your time and help!
> 
> My Elasticsearch setup uses a single shard with no replica. I am running  
> on a Rackspace cloud server. The works fine on my local Mac ☹
> 
> index.number\_of\_shards: 1  
> index.number\_of\_replicas: 0
> 
> No other changes in the config file.
> 
> My cluster state is green after starting es:
> 
> curl -XGET [http://localhost:9200/\_cluster/health](http://localhost:9200/_cluster/health)  
> \*  
> {"cluster\_name":"elasticsearch","status":"green","timed\_out":false,"number\_of\_nodes":1,"number\_of\_data\_nodes":1,"active\_primary\_shards":0,"active\_shards":0,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":0}  
> \*
> 
> When I start my app server, which uses the following to get a client...
> 
> _Node node = nodeBuilder().client(true).node();_  
> _client = node.client();_
> 
> I get the following exception when a search is sought to be executed:
> 
> ERROR [2012-06-28 00:37:34,229]  
> com.yammer.dropwizard.jersey.LoggingExceptionMapper: Error handling a  
> request: 8f94de3bc1f8f645! org.elasticsearch.cluster.block._ClusterBlockException:  
> blocked by: [SERVICE\_UNAVAILABLE/1/state not recovered /  
> initialized];[SERVICE\_UNAVAILABLE/2/no master];! at  
> org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException_  
> (ClusterBlocks.java:136)  
> ! at  
> org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(ClusterBlocks.java:126)  
> ! at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.(TransportSearchTypeAction.java:108)  
> ! at  
> org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.(TransportSearchDfsQueryThenFetchAction.java:76)  
> ! at  
> org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.(TransportSearchDfsQueryThenFetchAction.java:65)  
> ! at  
> org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:62)  
> ! at  
> org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:52)  
> ! at  
> org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)!  
> at  
> org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:106)  
> ! at  
> org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:43)  
> ! at  
> org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)  
> ! at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:83)  
> ! at  
> org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:206)

---

<div class="post-metadata">

### Author: ![pnayak](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pnayak](https://discuss.elastic.co/u/pnayak)
#### Post date: [June 28, 2012, 1:04pm UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244/3 "2012-06-28T13:04:30Z")

</div>

Thanks - it looks like multicast fails on Rackspace - for the time being  
I'm going to try unicast discovery...

---

<div class="post-metadata">

### Author: ![pnayak](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pnayak](https://discuss.elastic.co/u/pnayak)
#### Post date: [June 28, 2012, 6:10pm UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244/4 "2012-06-28T18:10:29Z")

</div>

Got it working. In case this helps anyone going forward, this is what I  
did to get Unicast working:

- Upgraded to ES 0.19.7 (was previously using 0.19.4)

- Disabled multicast discovery on my ES server by  
setting: discovery.zen.ping.multicast.enabled: false

- Note that I also used a single shard with no replicas since all I  
wanted for now was a single data node

- I did not specify discovery.zen.ping.unicast.hosts

- Created my Java client using:

.put("http.enabled", "false")  
.put("transport.tcp.port", "9300-9400")  
.put("discovery.zen.ping.multicast.enabled", "false")  
.put("discovery.zen.ping.unicast.hosts", "localhost").build();

Node node =  
nodeBuilder().client(true).settings(settings).clusterName("elasticsearch").node();  
client = node.client();

---

<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:22am UTC](https://discuss.elastic.co/t/java-client-unable-to-connect-clusterblockexception/8244/5 "2017-07-06T03:22:06Z")

</div>


