# Discovery.ec2.host\_type:public\_dns not working as expected

**URL:** <https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452>\
**Category:** Elasticsearch\
**Created:** [October 18, 2010, 7:47pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452 "2010-10-18T19:47:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [October 18, 2010, 7:47pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/1 "2010-10-18T19:47:45Z")

</div>

I have two nodes up in ec2 configured as follows:  
discovery:  
 type: ec2  
initial\_state\_timeout: 120s  
ec2:  
host\_type: public\_dns  
ports: 9300  
groups: dev\_private

I cannot connect to them running tests from nodes on my dev machine, trying to connect as follows:  
 NodeBuilder nb = NodeBuilder.nodeBuilder().client(true);  
nb.settings().put("discovery.zen.ping.multicast.enabled", "false");  
nb.settings().put("discovery.zen.ping.unicast.hosts", "[elasticsearch1.dev5.cloud.test.com:9300](http://elasticsearch1.dev5.cloud.test.com:9300),[elasticsearch2.dev5.cloud.test.com:9300](http://elasticsearch2.dev5.cloud.test.com:9300)");  
nb.settings().put("cluster.name", "dev5");  
this.indexClient = nb.node().client();

It still seems to try to join the nodes on private ip (the ip mentioned below, 10.198.109.171, is a private ip for one of the nodes):

12:42:14,757 WARN [elasticsearch[Fury][cached]-pool-3-thread-1] [discovery.zen] - [Fury] failed to connect to master [[Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/10.198.109.171:9300]]], retrying...  
org.elasticsearch.transport.ConnectTransportException: [Freakshow][inet[/10.198.109.171:9300]]  
Caused by: org.elasticsearch.transport.ConnectTransportException: [Freakshow][inet[/10.198.109.171:9300]]  
12:42:19,275 WARN [elasticsearch[Fury][cached]-pool-3-thread-1] [discovery.zen] - [Fury] failed to connect to master [[Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/10.198.109.171:9300]]], retrying...

It does that over and over until it gives up:

12:42:39,845 WARN [main] [discovery] - [Fury] waited for 30s and no initial state was set by the discovery

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 18, 2010, 8:33pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/2 "2010-10-18T20:33:59Z")

</div>

Hi,

Can you check in the logs of the nodes what is the `publish_host`? This is  
the one you want if you want to be able to connect to them. Currently, the  
ec2 discovery is not tied to the definition of what is the host the nodes  
will be connected to, so you will need to configure it as well.

Note, you don't have to configure it differently for each node. Usually,  
en1 will be the public one (if memory serves), so you can configure the  
`network.host` setting to _en1_. More info here:  
[http://www.elasticsearch.com/docs/elasticsearch/modules/node/network/](http://www.elasticsearch.com/docs/elasticsearch/modules/node/network/).

-shay.banon

On Mon, Oct 18, 2010 at 9:47 PM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> I have two nodes up in ec2 configured as follows:  
> discovery:  
> type: ec2  
> initial\_state\_timeout: 120s  
> ec2:  
> host\_type: public\_dns  
> ports: 9300  
> groups: dev\_private
> 
> I cannot connect to them running tests from nodes on my dev machine, trying  
> to connect as follows:  
> NodeBuilder nb = NodeBuilder.nodeBuilder().client(true);  
> nb.settings().put("discovery.zen.ping.multicast.enabled",  
> "false");  
> nb.settings().put("discovery.zen.ping.unicast.hosts",  
> "[elasticsearch1.dev5.cloud.test.com:9300](http://elasticsearch1.dev5.cloud.test.com:9300),  
> [elasticsearch2.dev5.cloud.test.com:9300](http://elasticsearch2.dev5.cloud.test.com:9300)");  
> nb.settings().put("cluster.name", "dev5");  
> this.indexClient = nb.node().client();
> 
> It still seems to try to join the nodes on private ip (the ip mentioned  
> below, 10.198.109.171, is a private ip for one of the nodes):
> 
> 12:42:14,757 WARN [elasticsearch[Fury][cached]-pool-3-thread-1]  
> [discovery.zen] - [Fury] failed to connect to master
> 
> [[Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/10.198.109.171:9300  
> ]]],  
> retrying...  
> org.elasticsearch.transport.ConnectTransportException:  
> [Freakshow][inet[/10.198.109.171:9300]]  
> Caused by: org.elasticsearch.transport.ConnectTransportException:  
> [Freakshow][inet[/10.198.109.171:9300]]  
> 12:42:19,275 WARN [elasticsearch[Fury][cached]-pool-3-thread-1]  
> [discovery.zen] - [Fury] failed to connect to master
> 
> [[Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/10.198.109.171:9300  
> ]]],  
> retrying...
> 
> It does that over and over until it gives up:
> 
> 12:42:39,845 WARN [main] [discovery] - [Fury] waited for 30s and no  
> initial  
> state was set by the discovery
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1727789.html](http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1727789.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [October 18, 2010, 10:18pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/3 "2010-10-18T22:18:01Z")

</div>

I'm sorry, I'm not sure I understand your response, but at any rate I think I failed for two reasons to give you a correct understanding of my situation.

We are trying to connect to two ec2-hosted elasticsearch nodes from outside the cloud. We don't have access to ec2's private IP space from our dev network, so we need the elasticsearch discovery to publish the public dns name of the instances (eg [ec2-204-236-195-66.compute-1.amazonaws.com](http://ec2-204-236-195-66.compute-1.amazonaws.com)), not an IP address. That public DNS name is the only way to access the elasticsearch nodes from both  
inside and outside the cloud. My dev machine outside the cloud is the one that produced the ConnectTransportException log errors copied above.

Also, the config of the nodes in the ec2 cloud I gave you was wrong. This is what I should have given you:  
discovery:  
host\_type: public\_dns  
type: zen  
zen:  
ping:  
unicast:  
hosts: [elasticsearch1.dev5.cloud.test.com](http://elasticsearch1.dev5.cloud.test.com)[9300],[elasticsearch2.dev5.cloud.test.com](http://elasticsearch2.dev5.cloud.test.com)[9300]  
enabled: true  
multicast:  
enabled: false

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 18, 2010, 10:32pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/4 "2010-10-18T22:32:33Z")

</div>

Can you try and connect using the transport client and not the node client?

On Tue, Oct 19, 2010 at 12:18 AM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> I'm sorry, I'm not sure I understand your response, but at any rate I think  
> I  
> failed for two reasons to give you a correct understanding of my situation.
> 
> We are trying to connect to two ec2-hosted elasticsearch nodes from outside  
> the cloud. We don't have access to ec2's private IP space from our dev  
> network, so we need the elasticsearch discovery to publish the public dns  
> name of the instances (eg [ec2-204-236-195-66.compute-1.amazonaws.com](http://ec2-204-236-195-66.compute-1.amazonaws.com)), not  
> an IP address. That public DNS name is the only way to access the  
> elasticsearch nodes from both  
> inside and outside the cloud. My dev machine outside the cloud is the one  
> that produced the ConnectTransportException log errors copied above.
> 
> Also, the config of the nodes in the ec2 cloud I gave you was wrong. This  
> is what I should have given you:  
> discovery:  
> host\_type: public\_dns  
> type: zen  
> zen:  
> ping:  
> unicast:  
> hosts:  
> [elasticsearch1.dev5.cloud.test.com](http://elasticsearch1.dev5.cloud.test.com)[9300],  
> [elasticsearch2.dev5.cloud.test.com](http://elasticsearch2.dev5.cloud.test.com)[9300]  
> enabled: true  
> multicast:  
> enabled: false
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1728737.html](http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1728737.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [October 18, 2010, 11:30pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/5 "2010-10-18T23:30:23Z")

</div>

Still can't connect, but the errors manifest differently.

I switched to connect the node in my dev machine (outside the ec2 cloud) this way:  
 indexClient = new TransportClient()  
.addTransportAddress(new InetSocketTransportAddress("", 9300))  
.addTransportAddress(new InetSocketTransportAddress("", 9300));

I can get through the above lines without exception, but I see in the logs:  
16:24:47,658 WARN [main] [client.transport] - [Rodstvow] Node [Jimmy Woo][06aff47a-c269-4ac0-9170-a64d4a66ced1][inet[/10.206.98.255:9300]] not part of the cluster Cluster [elasticsearch], ignoring...  
16:24:47,660 WARN [main] [client.transport] - [Rodstvow] Node [Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/10.198.109.171:9300]] not part of the cluster Cluster [elasticsearch], ignoring...

10.206.98.255 and 10.198.109.171 are still the private ip's only visible inside the ec2 cloud. Looking the logs of the nodes in the cloud, I don't see any evidence that I've joined.

Then, when I search I get a  
org.elasticsearch.client.transport.NoNodeAvailableException: No node available

By the way, once I get it to work with the Transport client, how do I set the cluster name?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 18, 2010, 11:43pm UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/6 "2010-10-18T23:43:34Z")

</div>

You need to set the cluster name on the transport client so it can join the  
cluster you started. When you construct a new TransportClient instance, you  
can pass it settings, in the settings, you can place "cluster.name" with the  
cluster name that you started the nodes with.

You won't see the client joining the nodes, as the transport client is not  
part of the cluster.

-shay.banon

On Tue, Oct 19, 2010 at 1:30 AM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> Still can't connect, but the errors manifest differently.
> 
> I switched to connect the node in my dev machine (outside the ec2 cloud)  
> this way:  
> indexClient = new TransportClient()  
> .addTransportAddress(new  
> InetSocketTransportAddress("", 9300))  
> .addTransportAddress(new  
> InetSocketTransportAddress("", 9300));
> 
> I can get through the above lines without exception, but I see in the logs:  
> 16:24:47,658 WARN [main] [client.transport] - [Rodstvow] Node [Jimmy  
> Woo][06aff47a-c269-4ac0-9170-a64d4a66ced1][inet[/10.206.98.255:9300]] not  
> part of the cluster Cluster [elasticsearch], ignoring...  
> 16:24:47,660 WARN [main] [client.transport] - [Rodstvow] Node  
> [Freakshow][594cc07f-6181-4794-87c5-7471ba31e70d][inet[/  
> 10.198.109.171:9300]]  
> not part of the cluster Cluster [elasticsearch], ignoring...
> 
> 10.206.98.255 and 10.198.109.171 are still the private ip's only visible  
> inside the ec2 cloud. Looking the logs of the nodes in the cloud, I don't  
> see any evidence that I've joined.
> 
> Then, when I search I get a  
> org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> available
> 
> ## By the way, once I get it to work with the Transport client, how do I set the cluster name?
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1729092.html](http://elasticsearch-users.115913.n3.nabble.com/discovery-ec2-host-type-public-dns-not-working-as-expected-tp1727789p1729092.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 4:17am UTC](https://discuss.elastic.co/t/discovery-ec2-host-type-public-dns-not-working-as-expected/3452/7 "2017-07-06T04:17:52Z")

</div>


