# Elasticsearch-hadoop spark connector unable to connect/write using out-of-box ES server setup, & default library settings

**URL:** <https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [October 14, 2020, 3:14am UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981 "2020-10-14T03:14:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Bedford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_bedford/32/77125_2.png) [@Chris\_Bedford](https://discuss.elastic.co/u/Chris_Bedford)\
**Post date:** [October 14, 2020, 3:14am UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981/1 "2020-10-14T03:14:37Z")

</div>

I had some problems using the Elasticsearch connector for Spark described here: [https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html](https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html). I could not even get the examples on their page working with a plain vanilla instance of Elasticsearch 7.4.0 that I downloaded and started via

```auto
<downloadDir>/bin/elasticsearch 

```

Here is what I did to run. I started Spark via the command:

```auto
spark-shell --packages "org.elasticsearch:elasticsearch-hadoop:7.4.0"

```

Then I typed in the lines from the code given on the documentation page referenced above:

```auto
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.elasticsearch.spark._

val numbers = Map("one" -> 1, "two" -> 2, "three" -> 3)
val airports = Map("arrival" -> "Otopeni", "SFO" -> "San Fran")

spark.sparkContext.makeRDD( Seq(numbers, airports)).saveToEs("spark/docs")

```

I got some strange errors indicating ES was connecting to something other than the default master node [127.0.0.1:9200], and then failing even with that node:

```auto
[Stage 0:> (0 + 12) / 12]20/10/13 19:39:21 ERROR NetworkClient: Node [172.20.0.3:9200] failed (org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 60000 ms); selected next node [127.0.0.1:9200]
20/10/13 19:39:21 ERROR NetworkClient: Node [172.20.0.3:9200] failed (org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 60000 ms); selected next node [127.0.0.1:9200]

```

Note that if I type [http://127.0.0.1:9200/](http://127.0.0.1:9200/) in my browser URL bar I get back a JSON doc indicating the cluster is up on localhost:9200. So, I'm stumped! Any guidance much appreciated.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 14, 2020, 8:01am UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981/2 "2020-10-14T08:01:33Z")

</div>

At the beginning of that message there is a mention of `172.20.0.3:9200` - where might that be coming from, as I assume that Elasticsearch is not listening on that IP by default.

---

<div class="post-metadata">

**Author:** ![Chris\_Bedford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_bedford/32/77125_2.png) [@Chris\_Bedford](https://discuss.elastic.co/u/Chris_Bedford)\
**Post date:** [October 14, 2020, 4:13pm UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981/3 "2020-10-14T16:13:46Z")

</div>

Hi.. re: that extra IP address. I am not sure. I did trace through the code a bit, and I found that IP add was being added somewhere here-\> [https://github.com/chenrun0210/elasticsearch-hadoop-7.0/blob/e7c263d8b2d65e4fa0023e1f1cbe762536819f4d/mr/src/main/java/org/elasticsearch/hadoop/rest/NetworkClient.java#L67](https://github.com/chenrun0210/elasticsearch-hadoop-7.0/blob/e7c263d8b2d65e4fa0023e1f1cbe762536819f4d/mr/src/main/java/org/elasticsearch/hadoop/rest/NetworkClient.java#L67). - I gave up on tracing through the problem since this is such a simple use case. I thought someone would see whatever dumb thing I did that is preventing this from working (hopefully).

---

<div class="post-metadata">

**Author:** ![Chris\_Bedford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_bedford/32/77125_2.png) [@Chris\_Bedford](https://discuss.elastic.co/u/Chris_Bedford)\
**Post date:** [October 16, 2020, 5:52pm UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981/4 "2020-10-16T17:52:29Z")

</div>

So, the problem was I had another instance of elasticsearch in another window listening on the same port. That always hoses things in strange ways. So.. this adapter has no problem at all. Problem was me.

---

<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 13, 2020, 5:52pm UTC](https://discuss.elastic.co/t/elasticsearch-hadoop-spark-connector-unable-to-connect-write-using-out-of-box-es-server-setup-default-library-settings/251981/5 "2020-11-13T17:52:31Z")

</div>

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