# Elasticsearch not working after enabling X-Pack

**URL:** https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [June 13, 2019, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564 "2019-06-13T07:47:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dhrumil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhrumil/32/46508_2.png) [@Dhrumil](https://discuss.elastic.co/u/Dhrumil)
#### Post date: [June 13, 2019, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/1 "2019-06-13T07:47:21Z")

</div>

Hello,  
I have installed elasticsearch version 6.8.0 in my production and have created a cluster with 3 master nodes and 20 data nodes. I have installed x-pack in all of the nodes and was trying to authenticate the cluster. For that, I enabled xpack security on 1 master node in the elasticsearch.yml file.  
For making changes to the config file and authenticating the node, I followed the below documentation:

> **[Secure Elasticsearch with TLS encryption and role-based access control](https://www.elastic.co/blog/getting-started-with-elasticsearch-security)**
>
> Secure your Elasticsearch clusters -- and the other components of the Elastic Stack -- with node-to-node TLS and role-based access control (RBAC). These features and more are now available free with the default distribution of Elasticsearch and...

After following those steps, when I ran the following command:  
sudo bin/elasticsearch-setup-passwords interactive

I received the following error:  
ERROR: Failed to connect to elasticsearch at [http://127.0.0.1:9200/\_xpack/security/\_authenticate?pretty](http://127.0.0.1:9200/_xpack/security/_authenticate?pretty). Is the URL correct and elasticsearch running?

For resolving this, I followed the below documentation:  
[https://www.elastic.co/guide/en/elastic-stack-overview/6.8/trb-security-setup.html](https://www.elastic.co/guide/en/elastic-stack-overview/6.8/trb-security-setup.html)

but could not solve the problem. Upon investigating further, I found that I don't have enough permissions to access the  
"elasticsearch.keystore" file. For that, I tried running the two commands:

sudo chown app:app /usr/local/etc/elasticsearch

sudo chmod g+ws /usr/local/etc/elasticsearch

" /usr/local/etc/elasticsearch" is the folder containg the "elasticsearch.keystore" file.  
But still, I am not able to resolve the issue.

Can anyone please help me?

Thanks.  
Dhrumil

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [June 13, 2019, 11:52pm UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/2 "2019-06-13T23:52:07Z")

</div>

> [@Dhrumil](#):
>
> Is the URL correct and elasticsearch running?

The first place to start is to answer those questions.

- Do you expect your node to be accessible via `http://127.0.0.1:9200` ? (Is it really bound to the local interface? Is it on port 9200?)
- If so, is your node running? What do the logs say?

---

<div class="post-metadata">

### Author: ![Dhrumil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhrumil/32/46508_2.png) [@Dhrumil](https://discuss.elastic.co/u/Dhrumil)
#### Post date: [June 14, 2019, 6:58am UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/3 "2019-06-14T06:58:31Z")

</div>

@TimV Thanks for the reply.  
I have taken care of the above issue. But, moving forward I am currently getting the following error when I am trying to run "elasticsearch-setup-passwords" command:

" _SSL connection to [https://10.12.218.37:9200/\_xpack/security/\_authenticate?pretty](https://10.12.218.37:9200/_xpack/security/_authenticate?pretty) failed: java.security.cert.CertificateException: No subject alternative names present_

_Please check the elasticsearch SSL settings under xpack.security.http.ssl._

_ERROR: Failed to establish SSL connection to elasticsearch at [https://10.12.218.37:9200/\_xpack/security/\_authenticate?pretty](https://10.12.218.37:9200/_xpack/security/_authenticate?pretty)._ "

In order to resolve this error, I followed this documentation and especially followed point 3:  
[https://www.elastic.co/guide/en/elastic-stack-overview/master/trb-security-setup.html](https://www.elastic.co/guide/en/elastic-stack-overview/master/trb-security-setup.html)

But still, I am unable to resolve the errors.  
Is there an issue with the certificate I have installed?

For installing the certificate, I have followed the steps described here:

> **[Secure Elasticsearch with TLS encryption and role-based access control](https://www.elastic.co/blog/getting-started-with-elasticsearch-security)**
>
> Secure your Elasticsearch clusters -- and the other components of the Elastic Stack -- with node-to-node TLS and role-based access control (RBAC). These features and more are now available free with the default distribution of Elasticsearch and...

---

<div class="post-metadata">

### Author: ![Dhrumil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhrumil/32/46508_2.png) [@Dhrumil](https://discuss.elastic.co/u/Dhrumil)
#### Post date: [June 14, 2019, 10:13pm UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/4 "2019-06-14T22:13:18Z")

</div>

@TimV I created those certificates again with the "--ip" parameter and then tried again setting up the password through "elastic-setup-passwords".  
But, this time I received the following error:  
"SSL connection to [https://10.12.218.37:9200/\_xpack/security/\_authenticate?pretty](https://10.12.218.37:9200/_xpack/security/_authenticate?pretty) failed: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target  
Please check the elasticsearch SSL settings under xpack.security.http.ssl. "

I have already set those parameters in config file.  
Currently, I am able to open the node in the browser with the link: [https://10.12.218.37:9200](https://10.12.218.37:9200)

But, for all the username and password combination it is failing and I am unable to access the cluster..

I tried setting up the "elastic" username's password by setting up the bootstrap password:  
sudo bin/elasticsearch-keystore add "bootstrap.password"

I also tried adding few more superusers with the following command:  
sudo bin/elasticsearch-users useradd user -p password -r superuser

Those users are added properly as I am able to confirm it with then following command:  
sudo bin/elasticsearch-users list

Still, I am unable to access my clusters as adding those username and passwords is not giving me access to the cluster.

Below is the config file:  
'''  
cluster.name: elasticsearch  
node.name: udl47Q8  
node.master: true  
node.data: true  
node.attr.rack: dfw  
cluster.routing.allocation.awareness.force.cloud.values: rack  
path.data: /data/elasticsearch  
path.logs: /data/log/elasticsearch  
bootstrap.memory\_lock: true  
network.host: 10.12.218.37  
http.port: 9200  
discovery.zen.ping.unicast.hosts: ["10.12.11.60", "10.12.15.110", "10.12.137.203", "10.12.11.89", "10.12.11.97", "10.12.120.219", "10.12.11.57", "10.12.15.92", "10.12.14.20", "10.12.15.178", "10.12.15.179", "10.12.30.211", "10.12.30.209", "10.12.30.210", "10.12.30.201","10.12.11.118", "10.12.13.103", "10.12.30.202", "10.12.24.223"]  
#discovery.zen.minimum\_master\_nodes: 2  
#gateway.recover\_after\_nodes: 3  
#gateway.expected\_nodes: 1  
action.destructive\_requires\_name: true  
http.cors.allow-origin: "\*"  
http.cors.enabled: true

#settings for x-pack  
xpack.security.enabled: true  
xpack.security.transport.ssl.enabled: true  
xpack.security.transport.ssl.verification\_mode: certificate  
xpack.security.transport.ssl.keystore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12  
xpack.security.transport.ssl.truststore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12  
xpack.security.http.ssl.enabled : true  
xpack.security.http.ssl.verification\_mode: full  
xpack.security.http.ssl.keystore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12  
xpack.security.http.ssl.truststore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12  
action.auto\_create\_index: .security,.monitoring\*,.watches,.triggered\_watches,.watcher-history\*,.ml\*  
'''

In my logs, I am also receiving the following error:  
" Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record elasticsearch "

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [June 17, 2019, 12:59am UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/5 "2019-06-17T00:59:10Z")

</div>

> [@Dhrumil](#):
>
> I have already set those parameters in config file.

Which parameters did you set?  
Please be specific in your posts - we cannot give you good advice if we're guessing.

> [@Dhrumil](#):
>
> ```auto
> xpack.security.transport.ssl.keystore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12
> xpack.security.transport.ssl.truststore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12
> xpack.security.http.ssl.keystore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12
> xpack.security.http.ssl.truststore.path: /usr/local/etc/elasticsearch/elastic-stack-ca.p12
> 
> ```

These all look to be incorrect. You should not be using a CA keystore for any of these settings.  
The blog post you claim to be following does not do that.

---

<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: [July 15, 2019, 12:59am UTC](https://discuss.elastic.co/t/elasticsearch-not-working-after-enabling-x-pack/185564/6 "2019-07-15T00:59:14Z")

</div>

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