MySQL Connector cannot connect to Elasticsearch Docker Instance

Hello

We are currently in the process of attempting to set up a locally running instance of Elasticsearch to connect to a MySQL database using Docker Containers but are unable to get this to work.

We are following the instructions in the following documents:

We first create the Docker network as required:
docker network create elastic

Setting up the Elasticsearch Container goes as expected and when running the following curl command the call to the URL is successful:
curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200

The command we use to create the Elasticsearch Container is:
docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.10.4

Once the Elasticsearch container has been created, when attempting to connect to the Elasticsearch Container via http://localhost:9200 using a web browser, the browser states that the response was empty. When attempting to connect to https://localhost:9200 via a web browser, the browser states that the connection is not trusted, however selecting the option to connect anyway then displays the message box to enter the user name and password which then successfully authenticates and displays the response from Elasticsearch as expected. We have copied the SSL certificate from the container and installed it to “Trusted Root Certification Authorities” (subfolder: Certificates) on the host machine (Local Machine) so that the connection to https://localhost:9200 is now trusted and does not show an error in the browser when trying to connect to this URL.

When setting up the Kibana instance, this works as expected although on the page where it requested the enrolment key the page displays the following under the text box where the enrolment key is to be entered:
Connect to https://172.18.0.2:9200

If we click the option to configure the connection manually and try to connect to either “http://localhost:9200” or “https://localhost:9200” the UI states that it cannot connect to either of these URLS.

The command we are using to create the Kibana Container is:
docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.10.4

We then go through the process to setup the connect to MySQL, going through the process in Kibana of setting up the API Key and creating the required config file then proceed to create the connector to MySQL via Docker, running the following command:
docker run ^
-v C:/connectors-config:/config ^
--network "elastic" ^
--tty ^
--rm ^
docker.elastic.co/enterprise-search/elastic-connectors:8.10.4.0-SNAPSHOT ^
/app/bin/elastic-ingest ^
-c /config/config.yml

When the connector is running the logs show that it cannot connect to the Elasticsearch Container instance (http://localhost:9200):
[FMWK][15:18:50][INFO] Waiting for NodeConfig(scheme='http', host='localhost', port=9200, path_prefix='', headers={}, connections_per_node=10, request_timeout=10.0, http_compress=False, verify_certs=True, ca_certs=None, client_cert=None, client_key=None, ssl_assert_hostname=None, ssl_assert_fingerprint=None, ssl_version=None, ssl_context=None, ssl_show_warn=True, _extras={}) (so far: 63 secs)
[FMWK][15:18:50][ERROR] Could not connect to the server
[FMWK][15:18:50][ERROR] Cannot connect to host localhost:9200 ssl:default [Connect call failed ('127.0.0.1', 9200)]
[FMWK][15:19:54][CRITICAL] http://localhost:9200 seem down. Bye!

We have also changed the configuration to also point to https://localhost:9200 but this returns the same error logs as above (except with “http” replaced with “https”).

I have also tried the same process pointing to “https://172.18.0.2:9200” however this returns the following error logs:
[FMWK][08:41:30][ERROR] Could not connect to the server
[FMWK][08:41:30][ERROR] Cannot connect to host 172.18.0.2:9200 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1007)')]
[FMWK][08:42:34][CRITICAL] https://172.18.0.2:9200 seem down. Bye!
[FMWK][08:42:34][INFO] Bye

This is all running locally on a Windows 10 machine (version: 22H2).

In light of the above, are you able to provide any guidance as to why the MySql connector cannot connect to Elasticsearch and if there are any other configuration setting s that need to be taken into account?

Are these 2 separate containers? if so localhost to connect to each other... will not work as 1 container's localhost is separate from the other container's localhost

Perhaps take a look at

in short, you will probably need to use host.docker.internal between the two containers

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.