# Error connecting to elasticsearch hosted on AWS via AWS EC2 instance

**URL:** <https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921>\
**Category:** Elasticsearch\
**Created:** [October 3, 2018, 4:51pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921 "2018-10-03T16:51:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shashank123hr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank123hr/32/33495_2.png) [@shashank123hr](https://discuss.elastic.co/u/shashank123hr)\
**Post date:** [October 3, 2018, 4:51pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921/1 "2018-10-03T16:51:07Z")

</div>

Hello

Can anyone please help me with an issue I am facing with regards to connecting to elasticsearch hosted on AWS. I am using the High level Rest client to make requests and running the java application as Jar.

Error that I am currently running into:  
java.net.ConnectException: Connection refused  
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:943)  
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:227)  
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1256)  
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1231)  
at org.elasticsearch.client.RestHighLevelClient.get(RestHighLevelClient.java:416)  
at org.onlineadvocate.elasticload.LoadTimeService.getLoadTime(LoadTimeService.java:82)  
at org.onlineadvocate.elasticload.ElasticSearchLoader.getLastLoadTime(ElasticSearchLoader.java:48)  
at org.onlineadvocate.elasticload.ElasticSearchLoader.loadSiteResourcesIntoElastic(ElasticSearchLoader.java:35)  
at org.onlineadvocate.elasticload.SiteLoader.loadSites(SiteLoader.java:50)  
at org.onlineadvocate.elasticload.SiteLoaderMain.main(SiteLoaderMain.java:28)  
Caused by: java.net.ConnectException: Connection refused  
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)  
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)  
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171)  
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145)  
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)  
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:192)  
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)  
at java.lang.Thread.run(Thread.java:748)

However, I was able to successfully make curl requests from the EC2 instance and receive successful response.

Thanks for your help.

---

<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:** [October 3, 2018, 5:20pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921/2 "2018-10-03T17:20:01Z")

</div>

Are you hosting it yourself?

May be share node logs and your code.  
Formatted please so it's readable

---

<div class="post-metadata">

**Author:** ![shashank123hr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank123hr/32/33495_2.png) [@shashank123hr](https://discuss.elastic.co/u/shashank123hr)\
**Post date:** [October 3, 2018, 6:36pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921/3 "2018-10-03T18:36:10Z")

</div>

I am not hosting the elasticsearch . We are using the AWS Elasticsearch service and unfortunately I don't have any node logs and cannot share the source code. We use High level Rest client to make requests and it runs just fine, if I make requests as part of War vs Jar.

---

<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:** [October 3, 2018, 6:51pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921/4 "2018-10-03T18:51:17Z")

</div>

I can't help then.

BTW did you look at [https://www.elastic.co/cloud](https://www.elastic.co/cloud) and [https://aws.amazon.com/marketplace/pp/B01N6YCISK](https://aws.amazon.com/marketplace/pp/B01N6YCISK) ?

Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL and what is coming like Canvas...

I'm using this one with the HLRest Client without any problem.

---

<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:** [October 31, 2018, 6:51pm UTC](https://discuss.elastic.co/t/error-connecting-to-elasticsearch-hosted-on-aws-via-aws-ec2-instance/150921/5 "2018-10-31T18:51:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
