Unable to access elasticsearch on localhost:9200

I am trying to run elasticsearch on docker, I am able to get my images up but unable to access localhost:9200, I am able to access kibana on localhost:5601 though.

Hi @Lim_Rik,

Are you receiving a particular error when you try to access Elasticsearch?

Yup that is correct, when I try to access elasticsearch server via http or when i send a curl request it does not return me a response

By default, elastic works over https instead of http.

Try to use

curl -X GET -k -u $User:$Password "https://localhost:9200/_cluster/health/?pretty"

The -k stands for insecure, in the case the cert is auto generated
The -u stands for provide user and password for access elastic

Great this works thanks!

Hey Keldane, when I run this command while setting up my constructor

docker run -v "C:/Users/Username/Documents/connectors-config:/config" --rm -it --network host docker.elastic.co/enterprise-search/elastic-connectors:8.13.4.0 /app/bin/elastic-ingest -c /config/config.yml

I get this error

[FMWK][05:27:20][INFO] Waiting for Elasticsearch at http://host.docker.internal:9200 (so far: 3 secs)
[FMWK][05:27:20][ERROR] Could not connect to the server
[FMWK][05:27:20][ERROR] Server disconnected

how do I get it to use https instead of http?
For reference, this is my config.yaml file

elasticsearch:
  host: https://host.docker.internal:9200  # Update the host value to use the correct Docker host with HTTPS
  ssl:
    enabled: true  # Enable SSL
  username: <username> # Replace with your Elasticsearch username
  password: <password>  # Replace with your Elasticsearch password
  api_key: <api_key>  # Add your Elasticsearch API key here

connectors:
  -
    connector_id: <connector_id>
    service_type: postgresql
    api_key: "<api_key>"  # Add your connector API key here

I don’t really know much about connectors, but try to hard pass the elastic ip to your config.yaml, also check that your elastic instance has the port 9200 open.

Also both containers should be in the same network for dns decoding, I’m not 100% sure about this last thing, but when I face a problem like that in my home lab, I always try to use the same network in order to solve those kind of issues.

The best approach is find in which network is your elastic container running, if you use the default docker run code that you find in the getting starter page ( Install Elasticsearch with Docker | Elasticsearch Guide [8.13] | Elastic )

It should being in network called elastic, otherwise, if it’s in a host network try to hard coding the ip


elasticsearch:
   host: https://$IpAddressDockerMachine:9200  # Update the host value to use the correct Docker host with HTTPS
     ssl:
    enabled: true  # Enable SSL
   username: <username> # Replace with your Elasticsearch username
  password: <password>  # Replace with your Elasticsearch password
  api_key: <api_key>  # Add your Elasticsearch API key here

 connectors:
   -
     connector_id: <connector_id>
     service_type: postgresql
     api_key: "<api_key>"  # Add your connector API key here

Where the $IpAddressDockerMachine is the ip for your machine and the ip interface which you are connected to internet

Pd: sorry for text formatting and syntax errors, I’m out of home right now replying in my phone, I will edit this post as soon as I arrive home

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