# Access secured Elasticsearch from Kibana

**URL:** <https://discuss.elastic.co/t/access-secured-elasticsearch-from-kibana/253460>\
**Category:** Kibana\
**Created:** [October 27, 2020, 3:37pm UTC](https://discuss.elastic.co/t/access-secured-elasticsearch-from-kibana/253460 "2020-10-27T15:37:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johann\_Hochtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johann_hochtl/32/77789_2.png) [@Johann\_Hochtl](https://discuss.elastic.co/u/Johann_Hochtl)\
**Post date:** [October 27, 2020, 3:37pm UTC](https://discuss.elastic.co/t/access-secured-elasticsearch-from-kibana/253460/1 "2020-10-27T15:37:20Z")

</div>

I configured elasticsearch to require ssl-communication, but not https via REST, see:

> [@Enabling security in Basic subscription](https://discuss.elastic.co/t/enabling-security-in-basic-subscription/253449):
>
> I am using elasticsearch 7.9, Basic subscription I followed [https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-security.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-security.html) I enabled security in elastic with this configuration: xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification\_mode: none xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12 xp…

I can access elastic from curl using the pattern

`curl -u kibana_system http://localhost:9200`

I configured Kibana as following:

```yaml
xpack.security.enabled: true
elasticsearch.username: "kibana_system"
elasticsearch.password: "123456"
xpack.security.encryptionKey: "ThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydog"
xpack.security.authc:
    providers:
        basic.basic1: 
            order: 0 

```

however the log reads:

{"type":"log","@timestamp":"2020-10-27T14:57:00Z","tags":["error","elasticsearch","monitoring"],"pid":7,"message":"Request error, retrying\nGET [http://localhost:9200/\_xpack](http://localhost:9200/_xpack) =\> connect ECONNREFUSED 127.0.0.1:9200"}  
{"type":"log","@timestamp":"2020-10-27T14:57:00Z","tags":["error","elasticsearch","data"],"pid":7,"message":"Request error, retrying\nGET [http://localhost:9200/\_nodes?filter\_path=nodes.\*.version%2Cnodes.\*.http.publish\_address%2Cnodes.\*.ip](http://localhost:9200/_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip) =\> connect ECONNREFUSED 127.0.0.1:9200"}

It seems as if the basic authentication request to elasticsearch is ignored. I already read

> **[Mutual TLS authentication between Kibana and Elasticsearch | Kibana Guide...](https://www.elastic.co/guide/en/kibana/current/elasticsearch-mutual-tls.html)**

So with my Basic plan this should be supported:

> If Kibana has `elasticsearch.username` and `elasticsearch.password` configured, it will attempt to use these to authenticate to Elasticsearch via the [native realm](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/native-realm.html)

I understand that the native realm is available with elasticsearch without configuration.

Please note that when I had no security configured within elastic, I could easily connect with Kibana.

Please help!

---

<div class="post-metadata">

**Author:** ![Johann\_Hochtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johann_hochtl/32/77789_2.png) [@Johann\_Hochtl](https://discuss.elastic.co/u/Johann_Hochtl)\
**Post date:** [October 28, 2020, 9:43am UTC](https://discuss.elastic.co/t/access-secured-elasticsearch-from-kibana/253460/2 "2020-10-28T09:43:03Z")

</div>

I solved the issue. It's all in the documentation:

> **[Install Kibana with Docker | Kibana Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/kibana/current/docker.html)**

> If replacing kibana.yml with a custom version, be sure to copy the defaults to the custom file if you want to retain them. If not, they will be "masked" by the new file.

So I had to add these new default values to my kibana.yml file and now I can access elasticsearch via kibana:

```yaml
xpack.security.enabled: true
elasticsearch.hosts: ["http://elastic:9200"]
server.host: "0"
elasticsearch.username: "kibana_system"
elasticsearch.password: "123456"
xpack.security.encryptionKey: "ThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydog"
xpack.security.authc:
    providers:
        basic.basic1: 
            order: 0 

```

I guess the crucial part was `server.host: "0"` as otherwise kibana is not accessible from anywhere but localhost = from within the docker container.

---

<div class="post-metadata">

**Author:** ![Vadims\_Daleckis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vadims_daleckis/32/57613_2.png) [@Vadims\_Daleckis](https://discuss.elastic.co/u/Vadims_Daleckis)\
**Post date:** [November 3, 2020, 1:44pm UTC](https://discuss.elastic.co/t/access-secured-elasticsearch-from-kibana/253460/3 "2020-11-03T13:44:18Z")

</div>


