Exception in thread "main" java.nio.file.AccessDeniedException while run ./bin/elasticsearch

I'm trying to install ElasticSearch in to my server.When i run ./bin/elasticsearch got bellow error

Exception in thread "main" java.nio.file.AccessDeniedException: /var/www/elasticsearch-7.3.1/config/jvm.options
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
	at java.base/java.nio.file.Files.newByteChannel(Files.java:370)
	at java.base/java.nio.file.Files.newByteChannel(Files.java:421)
	at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
	at java.base/java.nio.file.Files.newInputStream(Files.java:155)
	at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:61)

ElasticSearch : 7.3.1
Java : 11.0.4

inside Elasticsearch directory :

ubuntu@ip-14-0-0-129:/var/www/elasticsearch-7.3.1$ ll
total 564
drwxr-xr-x  9 root   root   4096 Sep 12 10:28 ./
drwxr-xr-x 11 root   root   4096 Sep 11 16:42 ../
-rw-r--r--  1 root   root   1024 Sep 12 10:28 .start.swp
-rw-r--r--  1 ubuntu root  13675 Aug 20 01:48 LICENSE.txt
-rw-r--r--  1 ubuntu root 502598 Aug 20 01:53 NOTICE.txt
-rw-r--r--  1 ubuntu root   8500 Aug 20 01:47 README.textile
drwxr-xr-x  2 ubuntu root   4096 Aug 20 01:58 bin/
drwxr-xr-x  2 ubuntu root   4096 Sep 12 10:40 config/
drwxr-xr-x  3 ubuntu root   4096 Aug 20 01:58 jdk/
drwxr-xr-x  3 ubuntu root   4096 Aug 20 01:58 lib/
drwxr-xr-x  2 ubuntu root   4096 Sep 12 10:40 logs/
drwxr-xr-x 33 ubuntu root   4096 Aug 20 01:58 modules/
drwxr-xr-x  2 ubuntu root   4096 Aug 20 01:53 plugins/
-rw-------  1 root   root      2 Sep 12 10:28 start.save

This error tells you that the Java process don't have access to read the file jvm.options, where all the important memory settings are, and therefore can't start Elasticsearch.

A common problem I've seen before is that people either install Elasticsearch as root or they try to run it as root, this always leads to conflict of file / directory ownership. In my view the best solution to this problem is to make sure that all files and directories are owned by the user one plans to run Elasticsearch with.

In your case, assuming that the user is ubuntu, you could do a recursive change owner like this:

sudo chown -R ubuntu /var/www/elasticsearh-7.3.1/

which will make ubuntu the owner of jvm.options and all other files. After that you should be able to start Elasticsearch using the ubuntu user.

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