title: EsHadoopIllegalArgumentException: Cannot detect ES version Spark-ElasticSearch example
body: <p>I am trying to run simple data write to ElasticSearch example. However, I keep getting this error:</p>
  
  <pre><code>EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens if the network/Elasticsearch cluster is not accessible or when targeting a WAN/Cloud instance without the proper setting 'es.nodes.wan.only
  </code></pre>
  
  <p>My dependencies for Spark and ElasticSearch:</p>
  
  <pre><code>scalaVersion := "2.11.5"
  
  val sparkVersion = "2.3.0"
  
  resolvers += "Spark Packages Repo" at "http://dl.bintray.com/spark-packages/maven"
  
  libraryDependencies ++= Seq(
    "org.apache.spark" %% "spark-core" % sparkVersion,
    "org.apache.spark" %% "spark-sql" % sparkVersion,
    "org.apache.spark" %% "spark-streaming" % sparkVersion,
    "com.typesafe" % "config" % "1.3.0",
    "org.elasticsearch" %% "elasticsearch-spark-20" % "6.2.4"
  )
  </code></pre>
  
  <p>Here is my code for an example:</p>
  
  <pre><code>object App {
  
    def main(args: Array[String]) {
      val sparkConf = new SparkConf()
        .setMaster(args(0))
        .setAppName("KafkaSparkStreaming")
      sparkConf.set("es.index.auto.create", "true")
  
      val sparkSession = SparkSession
        .builder()
        .config(sparkConf)
        .getOrCreate()
  
      val streamingContext = new StreamingContext(sparkSession.sparkContext, Seconds(3))
      val sparkContext = streamingContext.sparkContext
      sparkContext.setLogLevel("ERROR")
  
      val sqlContext = new SQLContext(sparkContext)
  
      val numbers = Map("one" -&gt; 1, "two" -&gt; 2, "three" -&gt; 3)
      val airports = Map("arrival" -&gt; "Otopeni", "SFO" -&gt; "San Fran")
  
      sparkContext.makeRDD(Seq(numbers, airports)).saveToEs("spark/docs")
  
      streamingContext.start()
      streamingContext.awaitTermination()
    }
  }
  </code></pre>
  
  <p>I run ElasticSearch with docker image. It is my docker-compose.yml file:</p>
  
  <pre><code>version: '3.3'
  services:
    kafka:
        image: spotify/kafka
        ports:
          - "9092:9092"
        environment:
        - ADVERTISED_HOST=localhost
    elasticsearch:
        image: elasticsearch
    kibana:
        image: kibana
        ports:
          - "5601:5601"
  </code></pre>
  
  <p>What might cause this exception? I would really appreciate some help.</p>