Exception in thread "main" java.net.ConnectException: Timeout connecting to [localhost:9200]

So I don't understand where this message was coming from:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "child \"method\" fails because [\"method\" must be one of [HEAD, GET, POST, PUT, DELETE]]",
  "validation": {
    "source": "query",
    "keys": [
      "method"
    ]
  }
}

BTW the fact that you hide the IP address or the URL makes me think that you are exposing your cluster on internet. Are you doing that?
If so, please, don't do it. At least without any security layer.

You can also look at cloud.elastic.co which contains everything you need as a service.