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

**URL:** <https://discuss.elastic.co/t/exception-in-thread-main-java-nio-file-accessdeniedexception-while-run-bin-elasticsearch/199177>\
**Category:** Elasticsearch\
**Created:** [September 12, 2019, 6:20am UTC](https://discuss.elastic.co/t/exception-in-thread-main-java-nio-file-accessdeniedexception-while-run-bin-elasticsearch/199177 "2019-09-12T06:20:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tje/32/53848_2.png) [@Tje](https://discuss.elastic.co/u/Tje)\
**Post date:** [September 12, 2019, 6:20am UTC](https://discuss.elastic.co/t/exception-in-thread-main-java-nio-file-accessdeniedexception-while-run-bin-elasticsearch/199177/1 "2019-09-12T06:20:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [September 12, 2019, 8:19am UTC](https://discuss.elastic.co/t/exception-in-thread-main-java-nio-file-accessdeniedexception-while-run-bin-elasticsearch/199177/2 "2019-09-12T08:19:20Z")

</div>

> [@Tje](#):
>
> Exception in thread "main" java.nio.file.AccessDeniedException: /var/www/elasticsearch-7.3.1/config/jvm.options

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.

---

<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:** [October 10, 2019, 8:19am UTC](https://discuss.elastic.co/t/exception-in-thread-main-java-nio-file-accessdeniedexception-while-run-bin-elasticsearch/199177/3 "2019-10-10T08:19:30Z")

</div>

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