# .StartupException: java.lang.RuntimeException: can not run elasticsearch as root

**URL:** <https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547>\
**Category:** Elasticsearch\
**Created:** [October 21, 2019, 8:06pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547 "2019-10-21T20:06:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sreekanth3](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sreekanth3](https://discuss.elastic.co/u/Sreekanth3)\
**Post date:** [October 21, 2019, 8:06pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/1 "2019-10-21T20:06:45Z")

</div>

I wanted to enable SSL on the elastic search , after adding the certificates , i need to restart the elasticsearch where it is throwing error.  
I have tried this by creating a user but it is showing error .i have attached that in below image

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/2/324ded9f119f971a68cda8028b3a8da309813723.png)

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [October 21, 2019, 8:52pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/2 "2019-10-21T20:52:34Z")

</div>

@Sreekanth3

You can't run ES via `sudo` when configuring a non-loopback host.  
Running ES from your `elastic` user fails because you seem to not be using an ES version with bundled JDK while the default java of your `elastic` user is a JDK8 version.

To make things work with your `elastic` user you must either point `JAVA_HOME` for that user at a valid JDK11 or better yet use an Elasticsearch distribution that comes with a bundled JDK.

---

<div class="post-metadata">

**Author:** ![Sreekanth3](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sreekanth3](https://discuss.elastic.co/u/Sreekanth3)\
**Post date:** [October 22, 2019, 3:08pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/3 "2019-10-22T15:08:05Z")

</div>

@Armin_Braun ,  
I have tried the way you suggested , Downloaded the JDK-11 and had set the JAVA\_HOME. The Warning which i got previously had gone. Is there any thing should i try , i need to get that started . after applying the SSL certificates , the error is popped.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/f/7fbdd9e1cb176116916d1737d068dce17cac9581.png)

---

<div class="post-metadata">

**Author:** ![Sreekanth3](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sreekanth3](https://discuss.elastic.co/u/Sreekanth3)\
**Post date:** [October 22, 2019, 3:42pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/4 "2019-10-22T15:42:34Z")

</div>

@Armin_Braun  
I somehow managed to get rid of the error ,but got stuck at this very point.  
Could you help me with this?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bd07f4985356107c48a6006371adb2e6f7342e5a.png)

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [October 22, 2019, 6:00pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/5 "2019-10-22T18:00:07Z")

</div>

@Sreekanth3 could it be that all the ES files are owned by `root` and the `elastic` user can't write to the ES (data-)folder? (looks looks like it)

---

<div class="post-metadata">

**Author:** ![Sreekanth3](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sreekanth3](https://discuss.elastic.co/u/Sreekanth3)\
**Post date:** [October 23, 2019, 3:29pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/6 "2019-10-23T15:29:42Z")

</div>

Hey @Armin_Braun I want to implement SSL certificates on my machine , I tried one way got failed . when i open my ES with http it's working , while i use https ES is not working.  
Could you suggest me one best way to implement SSL .[I have used this link](https://www.elastic.co/blog/elasticsearch-security-configure-tls-ssl-pki-authentication)

---

<div class="post-metadata">

**Author:** ![Sreekanth3](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Sreekanth3](https://discuss.elastic.co/u/Sreekanth3)\
**Post date:** [October 23, 2019, 3:33pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/7 "2019-10-23T15:33:53Z")

</div>

That was the correct , later i have changed the file permissions and it worked out.

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [October 23, 2019, 4:04pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/8 "2019-10-23T16:04:11Z")

</div>

@Sreekanth3 Could you open a new thread for this issue and clearly show/describe the steps you took and the error you're seeing in there?  
Thanks!

---

<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:** [November 20, 2019, 4:04pm UTC](https://discuss.elastic.co/t/startupexception-java-lang-runtimeexception-can-not-run-elasticsearch-as-root/204547/9 "2019-11-20T16:04:18Z")

</div>

Closed on November 20, 2019, 4:04pm UTC

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