# indexes-rebuilding

The database is **rebuilding its indexes** after an upgrade, which this request needs complete.

- **Routes:** `write-events`, `run-eventql-query`, `read-subjects`, `read-event-types`, `read-event-type`, `restore-backup`, `import-events`, and `verify-store`
- **Description:** `indexes are being rebuilt after an upgrade: try again later`
- **Details:** None; `details` is an empty object.

## Why It Happens

When a new version first starts on a data directory that an earlier one has written, it may **rebuild the index of subjects and the index of event types** from the events, in the background, see **[First Start After Upgrading](/docs/eventsourcingdb/upgrading#first-start-after-upgrading)**. Until they are complete, it refuses the requests that need them: listing subjects or event types, reading an event type, running an EventQL query, writing with an `isEventQlQueryTrue` precondition, whatever its query reads, verifying the store, restoring a backup, and importing events.

**Everything else goes on** meanwhile: reading and observing events, writing them without such a precondition, registering event schemas, auditing, and creating backups.

## How to Fix It

Wait until the rebuild has finished, then send the request again; **it can succeed then**. The **[health route](/docs/eventsourcingdb/logging-and-monitoring)** tells when that is: its check `store:indexes` says `rebuilding` while the rebuild runs, and `ready` once it has finished.

## Example

To list the event types while the indexes are being rebuilt, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its `end` item:

```json
{
  "type": "error",
  "data": {
    "code": "https://docs.eventsourcingdb.io/errors/indexes-rebuilding",
    "description": "indexes are being rebuilt after an upgrade: try again later",
    "details": {}
  }
}
```
