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.










share|improve this question























  • 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














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.










share|improve this question























  • 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












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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked Nov 9 at 15:09









Aleksandrs Antonovs

206




206











  • 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
















  • 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















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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














































































Popular posts from this blog

Darth Vader #20

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Ondo