Permission denied when running elasticsearch

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(
	at org.elasticsearch.bootstrap.Bootstrap.setup(
	at org.elasticsearch.bootstrap.Bootstrap.init(
	at org.elasticsearch.bootstrap.Elasticsearch.main(
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. /home/animesh/Documents/elasticsearch-2.1.0/logs/elasticsearch.log (Permission denied)
	at Method)
	at org.apache.log4j.FileAppender.setFile(
	at org.apache.log4j.FileAppender.activateOptions(
	at org.apache.log4j.DailyRollingFileAppender.activateOptions(
	at org.apache.log4j.config.PropertySetter.activate(
	at org.apache.log4j.config.PropertySetter.setProperties(
	at org.apache.log4j.config.PropertySetter.setProperties(
	at org.apache.log4j.PropertyConfigurator.parseAppender(
	at org.apache.log4j.PropertyConfigurator.parseCategory(
	at org.apache.log4j.PropertyConfigurator.configureRootCategory(
	at org.apache.log4j.PropertyConfigurator.doConfigure(
	at org.apache.log4j.PropertyConfigurator.configure(
	at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(
	at org.elasticsearch.bootstrap.Bootstrap.setupLogging(
	at org.elasticsearch.bootstrap.Bootstrap.init(
	at org.elasticsearch.bootstrap.Elasticsearch.main(
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.

1 Like

Something like?

chown -R youruser:yourgroup /home/animesh/Documents/elasticsearch-2.1.0
1 Like

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 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