# Spark scala "saveToEs" got the wrong ip

**URL:** <https://discuss.elastic.co/t/spark-scala-savetoes-got-the-wrong-ip/272269>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [May 6, 2021, 9:40am UTC](https://discuss.elastic.co/t/spark-scala-savetoes-got-the-wrong-ip/272269 "2021-05-06T09:40:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nameisnotimportant](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@nameisnotimportant](https://discuss.elastic.co/u/nameisnotimportant)\
**Post date:** [May 6, 2021, 9:40am UTC](https://discuss.elastic.co/t/spark-scala-savetoes-got-the-wrong-ip/272269/1 "2021-05-06T09:40:40Z")

</div>

Hi,  
I am trying spark and elasticsearch.  
setting:  
windows 10 pro  
spark version: 2.4.0  
scala version: 2.11.12  
ELK version: 7.10  
start like so:

> .\spark-shell --jars C:\spark\jars\elasticsearch-spark-20\_2.11-7.10.0.jar

code:

> import org.apache.spark.SparkContext  
> import org.apache.spark.SparkContext.\_  
> import org.elasticsearch.spark.\_  
> val elasticIndex = "pmolog"  
> val url = "**[http://109.111.21.26:9200](http://109.111.21.26:9200)**"
> 
> val reader = spark.sqlContext.read.  
> format("org.elasticsearch.spark.sql").  
> option("es.nodes.wan.only","false").  
> option("es.net.http.auth.user","elastic").  
> option("es.net.http.auth.pass","changeme").  
> option("es.nodes",url)
> 
> val df = reader.load(elasticIndex)

try to index into elasticsearch like below:

> import org.elasticsearch.spark.sql.\_  
> df.saveToEs("demoindex")

encounder error: (the url is different in the error message:)

> scala\> df.saveToEs("demoindex")  
> 2021-05-06 16:58:47 ERROR NetworkClient:155 - Node [127.0.0.1:9200] failed (Connection refused: connect); no other nodes left - aborting...
> 
> ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/4/14a9dc8fdf32735bc551a6134ba1f70ad0065399.png)

May i know how do i make sure it is looking for my url 109.111.21.26:9200 ?

---

<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:** [June 3, 2021, 9:41am UTC](https://discuss.elastic.co/t/spark-scala-savetoes-got-the-wrong-ip/272269/2 "2021-06-03T09:41:09Z")

</div>

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