ElasticSearch Connect Exception

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

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

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.

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

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

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

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.

What are elasticsearch logs?

Please format your code, logs or configuration files using </> icon as explained in this guide 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:

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.

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?

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