# Unable to access elasticsearch on localhost:9200

**URL:** <https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [May 28, 2024, 9:50am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368 "2024-05-28T09:50:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lim\_Rik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lim_rik/32/131373_2.png) [@Lim\_Rik](https://discuss.elastic.co/u/Lim_Rik)\
**Post date:** [May 28, 2024, 9:50am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/1 "2024-05-28T09:50:22Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/8/68479aa8afc0ad827bbaae09a81d23ec246e499c.png)

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [May 28, 2024, 10:46am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/2 "2024-05-28T10:46:00Z")

</div>

Hi @Lim_Rik,

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

---

<div class="post-metadata">

**Author:** ![Lim\_Rik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lim_rik/32/131373_2.png) [@Lim\_Rik](https://discuss.elastic.co/u/Lim_Rik)\
**Post date:** [May 28, 2024, 10:57am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/3 "2024-05-28T10:57:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Keldane](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@Keldane](https://discuss.elastic.co/u/Keldane)\
**Post date:** [May 28, 2024, 11:13am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/4 "2024-05-28T11:13:01Z")

</div>

By default, elastic works over https instead of http.

Try to use

```auto
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

---

<div class="post-metadata">

**Author:** ![Lim\_Rik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lim_rik/32/131373_2.png) [@Lim\_Rik](https://discuss.elastic.co/u/Lim_Rik)\
**Post date:** [May 29, 2024, 1:32am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/5 "2024-05-29T01:32:11Z")

</div>

Great this works thanks!

---

<div class="post-metadata">

**Author:** ![Lim\_Rik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lim_rik/32/131373_2.png) [@Lim\_Rik](https://discuss.elastic.co/u/Lim_Rik)\
**Post date:** [May 29, 2024, 5:35am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/6 "2024-05-29T05:35:38Z")

</div>

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

```auto
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

```auto
[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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Keldane](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@Keldane](https://discuss.elastic.co/u/Keldane)\
**Post date:** [May 29, 2024, 10:15am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/7 "2024-05-29T10:15:16Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html) )

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

```auto

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2024, 10:16am UTC](https://discuss.elastic.co/t/unable-to-access-elasticsearch-on-localhost-9200/360368/8 "2024-06-26T10:16:11Z")

</div>

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