# How to delete a write index that had no allocated shards

**URL:** <https://discuss.elastic.co/t/how-to-delete-a-write-index-that-had-no-allocated-shards/261304>\
**Category:** Elasticsearch\
**Created:** [January 16, 2021, 2:51am UTC](https://discuss.elastic.co/t/how-to-delete-a-write-index-that-had-no-allocated-shards/261304 "2021-01-16T02:51:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [January 16, 2021, 2:51am UTC](https://discuss.elastic.co/t/how-to-delete-a-write-index-that-had-no-allocated-shards/261304/1 "2021-01-16T02:51:26Z")

</div>

ES 7.10

original title: how can I delete a write index which has no allocated shards.

I started the post after struggling with this for a day but, as is often the case, the action of documenting the problem and and double checking the details I ended up solving it.

Having written this I thought someone else may profit from my experience...

I had a disaster with my custer where I lost a lot of shards belonging to over a 100 indexes. This also rendered kibana effectively dead -- everything just timed out.

GIven the kibana was dead I was reduced to using the API directly

I first deleted all indexes that were not green but one failed. That was the write index for a datastream as such is protected by ES. A write index is the current head of a datastream, i.e. the index that is currently being written.

I then tried to delete the datastream but ES insisted that it did not exist. I th

```auto
curl --noproxy localhost -X DELETE "localhost:9200//_data_stream/dns_ds"
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index []","resource.type":"index_expression","resource.id":"","index_uuid":"_na_","index":""}],"type":"index_not_found_exception","reason":"no such index []","resource.type":"index_expression","resource.id":"","index_uuid":"_na_","index":""},"status":404}

```

I then tried listing all datastreams and got the same error.

When I look in the logs of the ES servers I see errors about `all shards failed` no surprise there

ran `GET localhost:9200/_cluster/allocation/explain?pretty` and I found each node says  
`primary shard for this replica is not yet active` as the reason that it could not allocate the shard. This has a "catch 22" feel about it!.

I got kibana up by reinstalling and tweaked the config file to tell it to use a new set of indexes (.kibana-new).

I then deleted the data stream and now my cluster is finally GREEN again and I can look seriously seeing what I can restore from snapshots!

In hindsight I should have put my initial efforts into getting kibana up and running

I still don't know the answer to the original question why I could not delete the data stream from the API which was the fundamental problem

---

<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:** [February 13, 2021, 2:51am UTC](https://discuss.elastic.co/t/how-to-delete-a-write-index-that-had-no-allocated-shards/261304/2 "2021-02-13T02:51:27Z")

</div>

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