<p>I had created the a stateful set file for Elasticsearch 7.16.1 but on upgrading the ELK stack to 8.0.0, I get this error in the logs of the elastic pod:- <code>&quot;java.lang.IllegalStateException: failed to obtain node locks, tried [/usr/share/elasticsearch/data];</code> maybe these locations are not writable or multiple nodes were started on the same data path?</p>
<p>Likely root cause:</p>
<pre><code>java.nio.file.NoSuchFileException: /usr/share/elasticsearch/data/node.lock&quot;
</code></pre>
<p><a href="https://i.stack.imgur.com/aUk3i.png" rel="nofollow noreferrer">Elastic pod error</a></p>
<p>Kibana pod gives this error:-</p>
<pre><code>&quot;curl: (7) Failed to connect to elastic-cluster port 9200: Connection refused&quot;
</code></pre>
<p><a href="https://i.stack.imgur.com/Nmt4d.png" rel="nofollow noreferrer">Kibana pod error</a></p>
<p>I didn't get this error with the <strong>7.16.1</strong> version.</p>
<p>Should I make some changes in the statefulset files or any other files? Please help me solve this.</p>

Dolly
<p>Adding the following initContainers in my statefulset.yaml fixed the issue for me:</p>
<pre><code>initContainers:
- name: fix-permissions

  image: busybox

  command: [&quot;sh&quot;, &quot;-c&quot;, &quot;chown -R 1000:1000 /usr/share/elasticsearch/data&quot;]

  securityContext:

          privileged: true

  volumeMounts:

  - name: local-storage

    mountPath: /usr/share/elasticsearch/data
</code></pre>
