3

I'm using olivere's elastic go library (https://godoc.org/gopkg.in/olivere/elastic.v5) to create a connection to elasticsearch like so:

addr = "http://172.17.0.2:9200"
client, err := elastic.NewClient(elastic.SetURL(addr))

and am getting this error:

health check timeout: no Elasticsearch node available

Elasticsearch is running in a docker container and I am able to curl it from both my local machine and from the docker container. However, the go code (running on the docker container) is not able to connect to it.

curl -s -XGET 'http://172.17.0.2:9200/_nodes/http?pretty=1'
{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "pGBN2DBISgSZ8hd9lFgmHw" : {
      "name" : "pGBN2DB",
      "transport_address" : "127.0.0.1:9300",
      "host" : "127.0.0.1",
      "ip" : "127.0.0.1",
      "version" : "5.6.4",
      "build_hash" : "8bbedf5",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "http" : {
        "bound_address" : [
          "0.0.0.0:9200"
        ],
        "publish_address" : "172.17.0.2:9200",
        "max_content_length_in_bytes" : 104857600
      }
    }
  }
}

I'm using Docker for Mac. The publish address and IP are off, not sure if that has something to do with it. Would appreciate any help!

1 Answer 1

1

Edit /etc/elasticsearch/elasticsearch.yml to add the following line:

network.host: 0.0.0.0

This will allow connections from other IPs.

Possible duplicate of This question

Sign up to request clarification or add additional context in comments.

1 Comment

you will also need to add discovery.type: single-node or discovery.seed_hosts : ["localhost", "127.0.0.1"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.