# ElasticSearch Connect Exception

**URL:** <https://discuss.elastic.co/t/elasticsearch-connect-exception/205657>\
**Category:** Elasticsearch\
**Created:** [October 29, 2019, 11:43am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657 "2019-10-29T11:43:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![souravbasu45](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souravbasu45/32/56778_2.png) [@souravbasu45](https://discuss.elastic.co/u/souravbasu45)\
**Post date:** [October 29, 2019, 11:43am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/1 "2019-10-29T11:43:37Z")

</div>

I am getting a java.net.ConnectException: Timeout connecting when I am trying to connect to the ELasticSearch cluster at port 9200.

The error is as follows:  
java.net.ConnectException: Timeout connecting to [/172.29.57.160:9200]  
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:788)  
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:218)  
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:205)  
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1454)  
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)  
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)  
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)  
at com.ericsson.edos.automation.agent.automationagent.service.LogService.findAll(LogService.java:52)  
at com.ericsson.edos.automation.agent.automationagent.service.impl.AutomationServiceImpl.processAutomationLogs(AutomationServiceImpl.java:90)  
at com.ericsson.edos.automation.agent.automationagent.scheduler.AutomationScheduler.run(AutomationScheduler.java:26)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)  
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)  
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)  
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)  
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)  
at java.util.concurrent.FutureTask.run(Unknown Source)  
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)  
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)  
Caused by: java.net.ConnectException: Timeout connecting to [/172.29.57.160:9200]  
at org.apache.http.nio.pool.RouteSpecificPool.timeout(RouteSpecificPool.java:169)  
at org.apache.http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIOConnPool.java:628)  
at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.timeout(AbstractNIOConnPool.java:894)  
at org.apache.http.impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:183)  
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processTimeouts(DefaultConnectingIOReactor.java:210)  
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:155)  
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)  
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)  
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)  
... 1 more

Can anyone please suggest what can be done to fix it?

Thanks

---

<div class="post-metadata">

**Author:** ![Emiliano\_Baum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emiliano_baum/32/5186_2.png) [@Emiliano\_Baum](https://discuss.elastic.co/u/Emiliano_Baum)\
**Post date:** [October 29, 2019, 12:54pm UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/2 "2019-10-29T12:54:56Z")

</div>

What's your elastic version?  
this your Ingest node [/172.29.57.160:9200] ?  
How do you try to connect, with an app?

---

<div class="post-metadata">

**Author:** ![souravbasu45](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souravbasu45/32/56778_2.png) [@souravbasu45](https://discuss.elastic.co/u/souravbasu45)\
**Post date:** [October 29, 2019, 1:28pm UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/3 "2019-10-29T13:28:50Z")

</div>

I am using Elastic version 7.3.0. I am trying to connect with the Elastic cluster on our server, using my local system, and fetch the logs.

---

<div class="post-metadata">

**Author:** ![Emiliano\_Baum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emiliano_baum/32/5186_2.png) [@Emiliano\_Baum](https://discuss.elastic.co/u/Emiliano_Baum)\
**Post date:** [October 29, 2019, 1:40pm UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/4 "2019-10-29T13:40:12Z")

</div>

using curl? curl -XGET "172.29.57.160:9200/\_cluster/health?pretty" return a connection error message?

---

<div class="post-metadata">

**Author:** ![souravbasu45](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souravbasu45/32/56778_2.png) [@souravbasu45](https://discuss.elastic.co/u/souravbasu45)\
**Post date:** [October 30, 2019, 4:54am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/5 "2019-10-30T04:54:36Z")

</div>

using curl

curl -XGET "172.29.57.160:9200/\_cluster/health?pretty" on the local system does not give a response, the error is:

curl: (7) Failed to connect to 172.29.57.160 port 9200: Timed out

using curl -XGET "localhost:9200/\_cluster/health?pretty" gives a pretty json format object

---

<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 30, 2019, 5:18am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/6 "2019-10-30T05:18:27Z")

</div>

Either use `localhost` in your code or change `network.host` setting in your `elasticsearch.yml` file if you want elasticsearch to be available from other machines.

Read more at [https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html)

---

<div class="post-metadata">

**Author:** ![souravbasu45](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souravbasu45/32/56778_2.png) [@souravbasu45](https://discuss.elastic.co/u/souravbasu45)\
**Post date:** [October 30, 2019, 5:47am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/7 "2019-10-30T05:47:36Z")

</div>

> [@dadoonet](#):
>
> elasticsearch.yml

In our case we were using an older version of Elasticsearch and are only going for 7.3.0. The server port is listening to both 9200/9300. The curl script response for curl -XGET "localhost:9200/\_cluster/health?pretty" is:

{  
"cluster\_name" : "dummy\_cluster\_name,  
"status" : "yellow",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 56,  
"active\_shards" : 56,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 56,  
"delayed\_unassigned\_shards" : 0,  
"number\_of\_pending\_tasks" : 0,  
"number\_of\_in\_flight\_fetch" : 0,  
"task\_max\_waiting\_in\_queue\_millis" : 0,  
"active\_shards\_percent\_as\_number" : 50.0  
}

If I try to connect using port 9300, i get an exception that the port is not a http port.

For 9200, i get an connection timeout.

---

<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 30, 2019, 7:10am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/8 "2019-10-30T07:10:06Z")

</div>

What are elasticsearch logs?

---

<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 30, 2019, 7:10am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/9 "2019-10-30T07:10:23Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<div class="post-metadata">

**Author:** ![Emiliano\_Baum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emiliano_baum/32/5186_2.png) [@Emiliano\_Baum](https://discuss.elastic.co/u/Emiliano_Baum)\
**Post date:** [October 30, 2019, 11:38am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/10 "2019-10-30T11:38:35Z")

</div>

Your cluster is up, is you execute to allow rellocation of al the shards probably the cluster state change to green. This "unassigned\_shards" : 56 are probably the replicas.

`cluster.routing.allocation.enable`

Enable or disable allocation for specific kinds of shards:

- `all` - (default) Allows shard allocation for all kinds of shards.
- `primaries` - Allows shard allocation only for primary shards.
- `new_primaries` - Allows shard allocation only for primary shards for new indices.
- `none` - No shard allocations of any kind are allowed for any indices.

if you execute that you receive the actual configuration

```
    curl -X GET "localhost:9200/_cluster/settings?pretty"

```

Here where you have the tag "enable": "all" you have "primaries"

```
    `{"persistent" : { "cluster" : {"routing" : {"rebalance" : {"enable" : "all"},`

```

About the connection error, all the nodes in your cluster have the same elasticsearch version? In the update process you are following the steps for rolling upgrades?

---

<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:** [November 27, 2019, 11:38am UTC](https://discuss.elastic.co/t/elasticsearch-connect-exception/205657/11 "2019-11-27T11:38:41Z")

</div>

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