# Permission denied when running elasticsearch

**URL:** <https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383>\
**Category:** Elasticsearch\
**Created:** [January 16, 2016, 4:09pm UTC](https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383 "2016-01-16T16:09:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)\
**Post date:** [January 16, 2016, 4:09pm UTC](https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383/1 "2016-01-16T16:09:55Z")

</div>

I downloaded ES 2.1.0 as ran using the shell script available in `bin` folder.

```
animesh@ubuntu:~/Documents/elasticsearch-2.1.0/bin$ sudo ./elasticsearch
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

```

and if I run `elasticsearch` not as root:

```
animesh@ubuntu:~/Documents/elasticsearch-2.1.0/bin$ ./elasticsearch
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/animesh/Documents/elasticsearch-2.1.0/logs/elasticsearch.log (Permission denied)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
	at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
	at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
	at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
	at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
	at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
	at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
	at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
	at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
	at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
	at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
	at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
	at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
	at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:204)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:258)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [file]. ........
.
.
.
.

```

How should I correct those errors?

I am using Ubuntu 12.04.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 16, 2016, 4:32pm UTC](https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383/2 "2016-01-16T16:32:09Z")

</div>

Something like?

```auto
chown -R youruser:yourgroup /home/animesh/Documents/elasticsearch-2.1.0

```

---

<div class="post-metadata">

**Author:** ![Rinat](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@Rinat](https://discuss.elastic.co/u/Rinat)\
**Post date:** [January 17, 2017, 4:57pm UTC](https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383/3 "2017-01-17T16:57:19Z")

</div>

I have a similar issue and I've tried to play with permissions/folder ownership and it would not work.

I'm getting similar error : main ERROR Unable to create file /var/log/elasticsearch/elasticsearch.log java.io.IOException: Permission denied

And there are more lines to it but that seems to be the problem.

I ended up removing elasticsearch and reinstalling it and removing elasticsearch folder from /var/log but it still did not fix the issue. Any suggestions?

What should be done to /var/log directory itself?

Thanks a lot

---

<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 5, 2017, 10:04pm UTC](https://discuss.elastic.co/t/permission-denied-when-running-elasticsearch/39383/4 "2017-07-05T22:04:05Z")

</div>


