# Elasitc throwing error while connecting from Pivotal Colud foundry

**URL:** <https://discuss.elastic.co/t/elasitc-throwing-error-while-connecting-from-pivotal-colud-foundry/205495>\
**Category:** Elasticsearch\
**Created:** [October 28, 2019, 2:46pm UTC](https://discuss.elastic.co/t/elasitc-throwing-error-while-connecting-from-pivotal-colud-foundry/205495 "2019-10-28T14:46:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![varal12](https://avatars.discourse-cdn.com/v4/letter/v/b5ac83/32.png) [@varal12](https://discuss.elastic.co/u/varal12)\
**Post date:** [October 28, 2019, 2:46pm UTC](https://discuss.elastic.co/t/elasitc-throwing-error-while-connecting-from-pivotal-colud-foundry/205495/1 "2019-10-28T14:46:26Z")

</div>

We are using java high level rest client to connect to elastic search through spring boot. The spring boot application launches fine from workstation but when we deploy to Pivotal cloud foundry getting the following error intermittently. How to solve this problem?

Elastic search 6.7.2 installed on ubuntu 16.04  
Dependency in POM.xml files

```
    <dependency> 
		<groupId> org.elasticsearch</groupId> 
		<artifactId>elasticsearch</artifactId>  
		<version>6.4.3</version>
	</dependency> 
  	<dependency> 
		<groupId> org.elasticsearch.client</groupId> 
		<artifactId>elasticsearch-rest-high-level-client</artifactId> 
		<version>6.4.3</version> 
	</dependency>
	<dependency> 
		<groupId> org.elasticsearch.client</groupId> 
		<artifactId>elasticsearch-rest-client-sniffer</artifactId> 
		<version>6.4.3</version> 
	</dependency>

```

Error in PCF logs:

```auto
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] 2019-10-28 13:47:50.155 WARN 23 --- [nio-8080-exec-3] s.b.a.e.ElasticsearchRestHealthIndicator : Elasticsearch health check failed
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] java.net.ConnectException: Connection refused
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:943) ~[elasticsearch-rest-client-6.4.3.jar!/:6.4.3]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.elasticsearch.client.RestClient.performRequest(RestClient.java:227) ~[elasticsearch-rest-client-6.4.3.jar!/:6.4.3]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.elasticsearch.ElasticsearchRestHealthIndicator.doHealthCheck(ElasticsearchRestHealthIndicator.java:58) ~[spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:84) ~[spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:98) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:50) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2019-10-28T09:47:50.163-04:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.health.HealthEndpointWebExtension.getHealth(HealthEndpointWebExtension.java:75) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] Caused by: java.net.ConnectException: Connection refused
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_212]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_212]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171) ~[httpcore-nio-4.4.10.jar!/:4.4.10]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145) ~[httpcore-nio-4.4.10.jar!/:4.4.10]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) ~[httpcore-nio-4.4.10.jar!/:4.4.10]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221) ~[httpasyncclient-4.1.4.jar!/:4.1.4]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.4.jar!/:4.1.4]
2019-10-28T09:47:50.164-04:00 [APP/PROC/WEB/0] [OUT] ... 1 common frames omitted

```

---

<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 28, 2019, 5:16pm UTC](https://discuss.elastic.co/t/elasitc-throwing-error-while-connecting-from-pivotal-colud-foundry/205495/2 "2019-10-28T17:16:16Z")

</div>

`java.net.ConnectException: Connection refused` seems to say that you can't reach elasticsearch from the machine where your spring application is running.

Did you try to run a simple

```
curl ip:9200 

```

From the same machine?

---

<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 25, 2019, 5:16pm UTC](https://discuss.elastic.co/t/elasitc-throwing-error-while-connecting-from-pivotal-colud-foundry/205495/3 "2019-11-25T17:16:26Z")

</div>

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