# Can't connect to ec2 cluster using node client

**URL:** <https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631>\
**Category:** Elasticsearch\
**Created:** [June 15, 2011, 7:03pm UTC](https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631 "2011-06-15T19:03:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_H](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Drew\_H](https://discuss.elastic.co/u/Drew_H)\
**Post date:** [June 15, 2011, 7:03pm UTC](https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631/1 "2011-06-15T19:03:09Z")

</div>

Hi Folks,  
I have a two node ES cluster at EC2 set up, and I want to connect to  
the cluster from my local machine using this code:

```
    ImmutableSettings.Builder builder =

```

ImmutableSettings.settingsBuilder();  
builder.put("cluster.name", "MyCluster");  
builder.put("discovery.zen.multicast.enabled", false);  
builder.putArray("discovery.zen.ping.unicast.hosts", "host1",  
"host2");//host 1, host2 external EC2 DNS  
builder.put("node.local", "false");  
Node node =  
nodeBuilder().settings(builder).client(true).node();

Unfortunately, what seems to be occurring is that the nodes at EC2 are  
sending their internal EC2 ip addresses in ping responses to my local  
node and my local node can't respond affirmatively to those ips since  
they're EC2 internal. I've tried experimenting with the  
transport.publish\_host setting on the EC2 servers, but so far no  
luck. Any ideas on how this can work? The EC2 discovery module is  
not an option for me since my IT department does not want the EC2  
account information out in code.

Thanks,  
Drew

---

<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:** [June 15, 2011, 7:30pm UTC](https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631/2 "2011-06-15T19:30:09Z")

</div>

If you want to connect from your machine to the cluster on ec2, then the network.host should be the public ip. But, its better to use the TransportClient in this case.

On Wednesday, June 15, 2011 at 10:03 PM, Drew H wrote:

> Hi Folks,  
> I have a two node ES cluster at EC2 set up, and I want to connect to  
> the cluster from my local machine using this code:
> 
> ImmutableSettings.Builder builder =  
> ImmutableSettings.settingsBuilder();  
> builder.put("cluster.name ([http://cluster.name](http://cluster.name))", "MyCluster");  
> builder.put("discovery.zen.multicast.enabled", false);  
> builder.putArray("discovery.zen.ping.unicast.hosts", "host1",  
> "host2");//host 1, host2 external EC2 DNS  
> builder.put("node.local", "false");  
> Node node =  
> nodeBuilder().settings(builder).client(true).node();
> 
> Unfortunately, what seems to be occurring is that the nodes at EC2 are  
> sending their internal EC2 ip addresses in ping responses to my local  
> node and my local node can't respond affirmatively to those ips since  
> they're EC2 internal. I've tried experimenting with the  
> transport.publish\_host setting on the EC2 servers, but so far no  
> luck. Any ideas on how this can work? The EC2 discovery module is  
> not an option for me since my IT department does not want the EC2  
> account information out in code.
> 
> Thanks,  
> Drew

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [June 16, 2011, 12:02am UTC](https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631/3 "2011-06-16T00:02:59Z")

</div>

We use Maven to build our projects and our EC2 credentials are part of each  
users /.m2/settings.xml file. (At least those users who can deploy to EC2.)  
This keeps the credentials out of the codebase and version control.

-- jim

On Wed, Jun 15, 2011 at 3:03 PM, Drew H [hite.drew@gmail.com](mailto:hite.drew@gmail.com) wrote:

> Hi Folks,  
> I have a two node ES cluster at EC2 set up, and I want to connect to  
> the cluster from my local machine using this code:
> 
> ```
> ImmutableSettings.Builder builder =
> 
> ```
> 
> ImmutableSettings.settingsBuilder();  
> builder.put("cluster.name", "MyCluster");  
> builder.put("discovery.zen.multicast.enabled", false);  
> builder.putArray("discovery.zen.ping.unicast.hosts", "host1",  
> "host2");//host 1, host2 external EC2 DNS  
> builder.put("node.local", "false");  
> Node node =  
> nodeBuilder().settings(builder).client(true).node();
> 
> Unfortunately, what seems to be occurring is that the nodes at EC2 are  
> sending their internal EC2 ip addresses in ping responses to my local  
> node and my local node can't respond affirmatively to those ips since  
> they're EC2 internal. I've tried experimenting with the  
> transport.publish\_host setting on the EC2 servers, but so far no  
> luck. Any ideas on how this can work? The EC2 discovery module is  
> not an option for me since my IT department does not want the EC2  
> account information out in code.
> 
> Thanks,  
> Drew

---

<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:03am UTC](https://discuss.elastic.co/t/cant-connect-to-ec2-cluster-using-node-client/4631/4 "2017-07-06T04:03:24Z")

</div>


