Connect to elasticsearch 6.4 running in Docker from golang host application
up vote
0
down vote
favorite
Go ES client https://godoc.org/gopkg.in/olivere/elastic.v6 throws the "no active connection found: no Elasticsearch node available" error when attempting to connect from OS X host to ES running in docker container.
There's many discussions on how to solve it in v5.*, however, I couldn't find anything for v6.4.
Docker-compose part:
elasticsearch:
image: elasticsearch:6.4.2
network_mode: "bridge"
expose:
- "9200"
- "9300"
volumes:
- ./es-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
Go client call:
esClient, esClientErr :=
elastic.NewClient(elastic.SetURL("http://127.0.0.1:9200"))
if esClientErr != nil
return nil, fmt.Errorf("Failed to connect to ES: %v", esClientErr)
Output:
2018/11/09 15:57:54 Failed to connect to ES: no active connection found: no Elasticsearch node available
exit status 1
UPDATE
Setting network.publish_host: "_local_"
solved the problem. The publish_address
is set to 127.0.0.1:9300
now.
docker elasticsearch go docker-compose elasticsearch-6
add a comment |
up vote
0
down vote
favorite
Go ES client https://godoc.org/gopkg.in/olivere/elastic.v6 throws the "no active connection found: no Elasticsearch node available" error when attempting to connect from OS X host to ES running in docker container.
There's many discussions on how to solve it in v5.*, however, I couldn't find anything for v6.4.
Docker-compose part:
elasticsearch:
image: elasticsearch:6.4.2
network_mode: "bridge"
expose:
- "9200"
- "9300"
volumes:
- ./es-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
Go client call:
esClient, esClientErr :=
elastic.NewClient(elastic.SetURL("http://127.0.0.1:9200"))
if esClientErr != nil
return nil, fmt.Errorf("Failed to connect to ES: %v", esClientErr)
Output:
2018/11/09 15:57:54 Failed to connect to ES: no active connection found: no Elasticsearch node available
exit status 1
UPDATE
Setting network.publish_host: "_local_"
solved the problem. The publish_address
is set to 127.0.0.1:9300
now.
docker elasticsearch go docker-compose elasticsearch-6
Is the ES server actually running? Can youcurl
the same URL?
– David Maze
Nov 9 at 15:19
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…
– Peter
Nov 9 at 15:43
Could you share the output ofcurl http://127.0.0.1:9200
?
– daplho
Nov 9 at 21:56
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Go ES client https://godoc.org/gopkg.in/olivere/elastic.v6 throws the "no active connection found: no Elasticsearch node available" error when attempting to connect from OS X host to ES running in docker container.
There's many discussions on how to solve it in v5.*, however, I couldn't find anything for v6.4.
Docker-compose part:
elasticsearch:
image: elasticsearch:6.4.2
network_mode: "bridge"
expose:
- "9200"
- "9300"
volumes:
- ./es-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
Go client call:
esClient, esClientErr :=
elastic.NewClient(elastic.SetURL("http://127.0.0.1:9200"))
if esClientErr != nil
return nil, fmt.Errorf("Failed to connect to ES: %v", esClientErr)
Output:
2018/11/09 15:57:54 Failed to connect to ES: no active connection found: no Elasticsearch node available
exit status 1
UPDATE
Setting network.publish_host: "_local_"
solved the problem. The publish_address
is set to 127.0.0.1:9300
now.
docker elasticsearch go docker-compose elasticsearch-6
Go ES client https://godoc.org/gopkg.in/olivere/elastic.v6 throws the "no active connection found: no Elasticsearch node available" error when attempting to connect from OS X host to ES running in docker container.
There's many discussions on how to solve it in v5.*, however, I couldn't find anything for v6.4.
Docker-compose part:
elasticsearch:
image: elasticsearch:6.4.2
network_mode: "bridge"
expose:
- "9200"
- "9300"
volumes:
- ./es-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
Go client call:
esClient, esClientErr :=
elastic.NewClient(elastic.SetURL("http://127.0.0.1:9200"))
if esClientErr != nil
return nil, fmt.Errorf("Failed to connect to ES: %v", esClientErr)
Output:
2018/11/09 15:57:54 Failed to connect to ES: no active connection found: no Elasticsearch node available
exit status 1
UPDATE
Setting network.publish_host: "_local_"
solved the problem. The publish_address
is set to 127.0.0.1:9300
now.
docker elasticsearch go docker-compose elasticsearch-6
docker elasticsearch go docker-compose elasticsearch-6
edited 2 days ago
asked Nov 9 at 15:09
Aleksandrs Antonovs
206
206
Is the ES server actually running? Can youcurl
the same URL?
– David Maze
Nov 9 at 15:19
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…
– Peter
Nov 9 at 15:43
Could you share the output ofcurl http://127.0.0.1:9200
?
– daplho
Nov 9 at 21:56
add a comment |
Is the ES server actually running? Can youcurl
the same URL?
– David Maze
Nov 9 at 15:19
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…
– Peter
Nov 9 at 15:43
Could you share the output ofcurl http://127.0.0.1:9200
?
– daplho
Nov 9 at 21:56
Is the ES server actually running? Can you
curl
the same URL?– David Maze
Nov 9 at 15:19
Is the ES server actually running? Can you
curl
the same URL?– David Maze
Nov 9 at 15:19
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…– Peter
Nov 9 at 15:43
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…– Peter
Nov 9 at 15:43
Could you share the output of
curl http://127.0.0.1:9200
?– daplho
Nov 9 at 21:56
Could you share the output of
curl http://127.0.0.1:9200
?– daplho
Nov 9 at 21:56
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228324%2fconnect-to-elasticsearch-6-4-running-in-docker-from-golang-host-application%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Is the ES server actually running? Can you
curl
the same URL?– David Maze
Nov 9 at 15:19
Yes, and Kibana successfully connects to it. But the client tries to hit the publish_address value which is set to docker network (172.17.0.2:9300). The question is how to configure it correspondingly.
– Aleksandrs Antonovs
Nov 9 at 15:20
-E network.publish_host=_docker0_
elastic.co/guide/en/elasticsearch/reference/6.4/…– Peter
Nov 9 at 15:43
Could you share the output of
curl http://127.0.0.1:9200
?– daplho
Nov 9 at 21:56