Skip to content

Connection Problems

Oliver Eilhard edited this page Aug 31, 2015 · 26 revisions

This page describes what to do when you cannot get Elastic to connect to an Elasticsearch node or cluster.

You can provide one or more URLs to NewClient(...) that Elastic will use to connect to a node/a cluster. On startup, Elastic will make sure to have at least one working connection. if Elastic does not find an active connection, NewClient(...) will fail straight away with error elastic.ErrNoClient.

How to figure out connection problems?

When sniffing is enabled (the default), Elastic uses the Nodes Info API to find all nodes in the cluster. After it finds these nodes, it updates the internal list of connections and keeps it updated periodically.

Now most connection problems get reported because Elastic either cannot invoke the Nodes Info API or the Nodes Info API reports back IP:port combinations that are not accessible to Elastic. For example, in a typical Docker installation, sometimes internal IP:port combinations are returned. Unfortunately, those internal IP:port combinations are only accessible from within the Docker container. If that happens, you need to e.g. change the network bindings of Elasticsearch to bind to externally accessible network interfaces. There's a separate page on Docker as well.

Here's what the Nodes Info API typically returns and what Elastic uses to find the IP:port combination for the nodes of a cluster:

$ curl -s -XGET 'http://127.0.0.1:9200/_nodes/http?pretty=1'
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "ULKrjqidS_SvgqYgl24JhQ" : {
      "name" : "Medusa",
      "transport_address" : "inet[localhost/127.0.0.1:9300]",
      "host" : "aero",
      "ip" : "192.168.1.2",
      "version" : "1.7.1",
      "build" : "b88f43f",
      "http_address" : "inet[/127.0.0.1:9200]",
      "http" : {
        "bound_address" : "inet[/127.0.0.1:9200]",
        "publish_address" : "inet[/127.0.0.1:9200]",
        "max_content_length_in_bytes" : 104857600
      }
    }
  }
}

You can see that the http_address field contains the IP:port combination of the node. If you can curl this address from the server that Elastic runs on, there shouldn't be any connection problems.

Clone this wiki locally