title: Failed to start Elasticsearch. Error opening log file '/gc.log': Permission denied
body: <p>Dear StackOverflow community,</p>
  
  <p>I was running Kibana/Elasticsearch without a problem until installing a Kibana plugin. Then the service failed and I noticed that the problem is that Elasticsearch stopped. I tried several ways to fix it, and then even reinstalled all. But the problem still avoiding to launch Elasticsearch, even with a fresh installation.</p>
  
  <p>Installation on Debian 9 using apt install.</p>
  
  <p><code>systemctl start elasticsearch.service</code></p>
  
  <p>results on:</p>
  
  <p><code>Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]</code></p>
  
  <p><code>[0.000s][error][logging] Error opening log file '/gc.log': Permission denied</code></p>
  
  <p>Full log with <code>journalctl -xe</code> </p>
  
  <pre><code>-- Unit elasticsearch.service has begun starting up.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal kibana[576]: {"type":"log","@timestamp":"2020-02-07T13:09:06Z","tags":["warning","elasticsearch","admin"],"pid":576,"message":"Unable to revive connection: http://localhost:9200/"}
  Feb 07 14:09:06 Debian-911-stretch-64-minimal kibana[576]: {"type":"log","@timestamp":"2020-02-07T13:09:06Z","tags":["warning","elasticsearch","admin"],"pid":576,"message":"No living connections"}
  Feb 07 14:09:06 Debian-911-stretch-64-minimal kibana[576]: {"type":"log","@timestamp":"2020-02-07T13:09:06Z","tags":["warning","elasticsearch","admin"],"pid":576,"message":"Unable to revive connection: http://localhost:9200/"}
  Feb 07 14:09:06 Debian-911-stretch-64-minimal kibana[576]: {"type":"log","@timestamp":"2020-02-07T13:09:06Z","tags":["warning","elasticsearch","admin"],"pid":576,"message":"No living connections"}
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: output:
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: [0.000s][error][logging] Error opening log file '/gc.log': Permission denied
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: [0.000s][error][logging] Initialization of output 'file=/var/log/elasticsearch/gc.log' using options 'filecount=32,filesize=64m' failed.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: error:
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m', see error log for details.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: Error: Could not create the Java Virtual Machine.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]: Error: A fatal exception has occurred. Program will exit.
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]:         at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:118)
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]:         at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:86)
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]:         at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
  Feb 07 14:09:06 Debian-911-stretch-64-minimal elasticsearch[2312]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:92)
  Feb 07 14:09:06 Debian-911-stretch-64-minimal systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
  Feb 07 14:09:06 Debian-911-stretch-64-minimal systemd[1]: Failed to start Elasticsearch.
  -- Subject: Unit elasticsearch.service has failed
  -- Defined-By: systemd
  -- Support: https://www.debian.org/support
  -- 
  -- Unit elasticsearch.service has failed.
  </code></pre>
  
  <p>The mentioned gc.log file was not in that folder. And the permissions were:</p>
  
  <p><code>drwxr-s---  2 elasticsearch elasticsearch       4096 Jan 15 13:20 elasticsearch</code></p>
  
  <p>I created the file and also played with permissions until having these:</p>
  
  <p><code>-rwxrwxrwx 1 root elasticsearch 0 Feb  7 15:19 gc.log</code></p>
  
  <p>...and even changed the ownership:</p>
  
  <p><code>-rwxrwxrwx 1 root root 0 Feb  7 15:19 gc.log</code></p>
  
  <p>But no success, I still having the same issue.</p>
  
  <p>Thanks</p>