Elasticsearch7 (ES7) support connect ECONNREFUSED

So I have followed all the steps to install vsf with ES7 with this doc https://docs.vuestorefront.io/guide/cookbook/elastic.html#_2-recipe-3. But I always redirected to http://localhost:3000/error. So when I tried debugging from vsf to vsf api.
I found this error on vsf front:
Can not connect the vue-storefront-api / ElasticSearch instance! Error: FetchError in request to ES: FetchError: invalid json response body at http://localhost:8080/api/catalog/vue_storefront_catalog/attribute/_search

and this on vsf api log:
{ Error: connect ECONNREFUSED elasticsearch:9200
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
syscall: ‘connect’,
address: ‘elasticsearch’,
port: 9200 }

First, I think it was because the address is “elasticsearch” (eventhough the local.json config is set to “localhost”), so I tried to hardcoded it to “localhost” or “” but I still get the same error.

I tried open the elastic url on the browser to check if the elastic server is running successfully (http://localhost:9200/vue_storefront_catalog_product/_search), it shows some result.

Thank you in advance.

Seemingly there is no connectivity between your docker containers. You can set different endpoints for SSR / CSR mode and this option could potentially solve this issue: https://github.com/DivanteLtd/vue-storefront/issues/2861

I’m not sure about it. I forgot to mention that eveything is works with ES5.6, but with ES7.1 I got this problem. It is really about SSR / CSR? I mean, what is the relation between ES with SSR / CSR?

Hello Hanson_Citra, did you get this solved? I have exactly the same problem: it works fine with ES5.6 but breaks with 7.1 it ECONNREFUSED. I followed the docs and I had a look at issue 2861 but it does not seem to be the same problem as my docker containers are within the same network. The solution presented there is also a bit unclear as to where I have to change what.
But maybe I go wrong at point 5 Once Elasticsearch 7 instance is up and running, then run the new script which creates index with the proper data types of fields applied.
yarn db7 new"
because it is not explained where to run that command? In es7 (the elasticsearch7 container) I get OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused “exec: “yarn”: executable file not found in $PATH”: unknown
and in directory of vue-storefront-api I get
“error Command “db7” not found.”
so I’m at loss as where to do that command… and if I go into the es7 container it will say bash: yarn: command not found…

Hi, I had this problem too when trying to switch to ES7.
After some digging, I came to notice that it’s a docker configuration problem, because the API container tries to reach the ‘elasticsearch’ container, which does not exist with that name.
In docker-compose.elastic7.yml you have to change ‘container_name’: write ‘elasticsearch’ instead of ‘es7’.
I think it should be fixed in the repo too.