> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/elasticsearch.md).

# Elasticsearch-related issues

Troubleshoot Elasticsearch (ES) indices that become locked in read-only mode in SonarQube Server 10.8.

{% hint style="info" %}
**For AI agents:** You're in the SonarQube Server 10.8 documentation. For a list of all 10.8 pages, see the [SonarQube Server 10.8 page index](https://312504542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiJj3TXBdWssTGGg8qK5I%2Fuploads%2FmeJ1nVNGPezOurNrTy4A%2Fsonarqube-server-10.8-llms.txt?alt=media). For the whole site, see the [page index](https://docs.sonarsource.com/llms.txt) or the [full text](https://docs.sonarsource.com/llms-full.txt). For another version, replace 10.8 in the URL with that version. The [latest version](https://docs.sonarsource.com/sonarqube-server/) has no version number in its URL.
{% endhint %}

## Recovering from Elasticsearch read-only indices <a href="#recovering-from-elasticsearch-read-only-indices" id="recovering-from-elasticsearch-read-only-indices"></a>

You may encounter issues with Elasticsearch (ES) indices becoming locked in read-only mode. ES requires free disk space available and implements a safety mechanism to prevent the disk from being flooded with index data that:

* **For non-DCE** – locks all indices in read-only mode when the 95% used disk usage watermark is reached.
* **For DCE** – locks all or some indices in read-only mode when one or more node reaches the 95% used disk usage watermark.

ES shows warnings in the logs as soon as disk usage reaches 85% and 90%. At 95% usage and above, indices turning read-only causes errors in the web and compute engine.

Freeing disk space will *not* automatically make the indices return to read-write. To make indices read-write, you also need to:

* **For non-DCE** – restart SonarQube Server.
* **For DCE** – restart *ALL* application nodes (the first application node restarted after all have been stopped will make the indices read-write).

SonarQube Server’s built-in resilience mechanism allows SonarQube Server to eventually recover from the indices being behind data in the DB (this process can take a while).

If you still have inconsistencies, you’ll need to rebuild the indices (this operation can take a long time depending on the number of issues and components):

**non-DCE:**

1. Stop SonarQube Server.
2. Delete the `data/es8` directory.
3. Restart SonarQube Server.

**DCE:**

1. Stop the whole cluster (ES and application nodes).
2. Delete the `data/es8` directory on each ES node.
3. Restart the whole cluster.

{% hint style="info" %}
See [Operating the DCE cluster](/sonarqube-server/10.8/setup-and-upgrade/configure-and-operate-a-cluster.md) for information on stopping and starting a cluster.
{% endhint %}

## Failed background tasks during reindexing <a href="#failed-tasks-during-reindexing" id="failed-tasks-during-reindexing"></a>

During Elasticsearch reindexing, you may have failed tasks in your branches or pull requests:

* If you only have a few failed tasks, you can reanalyze your branch or pull request. You may want to use web services to remove branches and pull requests that can’t be reanalyzed because they have been removed from version control.
* If you have many failed tasks, you may want to delete your Elasticsearch directory and reindex again. To do so, see **Forcing an Elasticsearch reindex** on the [Reindexing](/sonarqube-server/10.8/server-upgrade-and-maintenance/maintenance/reindexing.md) page.

If background tasks of type **Project Data Reload** fail for a particular project, see **Reindexing a single project** on the [Reindexing](/sonarqube-server/10.8/server-upgrade-and-maintenance/maintenance/reindexing.md) page.

## Exception java.lang.RuntimeException: cannot run elasticsearch as root <a href="#elasticsearch" id="elasticsearch"></a>

SonarQube Server starts an Elasticsearch process, and the same account that is running SonarQube Server itself will be used for the Elasticsearch process. Since Elasticsearch cannot be run as root, that means SonarQube Server can’t be either. You must choose some other, non-root account with which to run SonarQube Server, preferably an account dedicated to the purpose.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [Checking the server logs](/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/checking-server-logs.md)
* [Performance issues](/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/performance-issues.md)
* [Database-related issues](/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/database-related-issues.md)
* [Other issues](/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/other-issues.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-server/10.8/server-upgrade-and-maintenance/troubleshooting/elasticsearch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
