# How to set up security for elasticsearch cluster

**URL:** <https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [August 16, 2021, 1:45pm UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552 "2021-08-16T13:45:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 16, 2021, 1:45pm UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/1 "2021-08-16T13:45:18Z")

</div>

```auto
network.host: ip1

discovery.seed_hosts: ["ip1", "ip2"]

cluster.initial_master_nodes: ["ip1"]

```

```auto

network.host: ip2

discovery.seed_hosts: ["ip1", "ip2"]

cluster.initial_master_nodes: ["ip1"]

```

these are two yml files on two servers

how do i set up security for this cluster?

after enabling x-pack security  
and running this  
./bin/elasticsearch-setup-passwords auto

i am getting this error

> Connection failure to: [http://ip1:9200/\_security/\_authenticate?pretty](http://ip1:9200/_security/_authenticate?pretty) failed: Connection refused
> 
> ERROR: Failed to connect to elasticsearch at [http://ip1:9200/\_security/\_authenticate?pretty](http://ip1:9200/_security/_authenticate?pretty). Is the URL correct and elasticsearch running?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 16, 2021, 10:01pm UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/2 "2021-08-16T22:01:41Z")

</div>

Have you been through [Configure security for the Elastic Stack | Elasticsearch Guide [7.14] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/configuring-stack-security.html)?

---

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 17, 2021, 5:26am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/3 "2021-08-17T05:26:56Z")

</div>

yes, this error is coming when i try to generate passwords using

```auto
./bin/elasticsearch-setup-password auto

```

> Connection failure to: [http://ip1:9200/\_security/\_authenticate?pretty](http://ip1:9200/_security/_authenticate?pretty) failed: Connection refused
> 
> ERROR: Failed to connect to elasticsearch at [http://ip1:9200/\_security/\_authenticate?pretty](http://ip1:9200/_security/_authenticate?pretty). Is the URL correct and elasticsearch running?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2021, 5:39am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/4 "2021-08-17T05:39:09Z")

</div>

Ok, so what does Elasticsearch say when it starts up, because it needs to be running for that command to work.

---

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 17, 2021, 5:48am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/5 "2021-08-17T05:48:29Z")

</div>

Yes it is running

with network host ip1

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2021, 5:50am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/6 "2021-08-17T05:50:10Z")

</div>

Can you `curl ip1:9200` and get a response?

---

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 17, 2021, 5:53am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/7 "2021-08-17T05:53:27Z")

</div>

connection refuse is coming up

but if i remove x-pack security the its working

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2021, 5:55am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/8 "2021-08-17T05:55:19Z")

</div>

You'll need to show us your Elasticsearch logs then.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 17, 2021, 5:58am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/9 "2021-08-17T05:58:55Z")

</div>

It looks like you have more than one node which requires TLS to be set up. Have you done this?

---

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 17, 2021, 6:02am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/10 "2021-08-17T06:02:26Z")

</div>

In doc, It is stated in that

> After adding password protection in the [minimal security configuration](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-minimal-setup.html), you’ll need to configure Transport Layer Security (TLS).

but failing to add password protection

---

<div class="post-metadata">

**Author:** ![0d153a83fd88577dba87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0d153a83fd88577dba87/32/92002_2.png) [@0d153a83fd88577dba87](https://discuss.elastic.co/u/0d153a83fd88577dba87)\
**Post date:** [August 17, 2021, 6:42am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/11 "2021-08-17T06:42:34Z")

</div>

Should i do tls before minimul security configuration ?

---

<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:** [September 14, 2021, 6:43am UTC](https://discuss.elastic.co/t/how-to-set-up-security-for-elasticsearch-cluster/281552/12 "2021-09-14T06:43:29Z")

</div>

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