# Blocked by: \[FORBIDDEN/5/index read-only (api)\];

**URL:** <https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956>\
**Category:** Elasticsearch\
**Created:** [April 9, 2019, 6:06am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956 "2019-04-09T06:06:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gnanendra](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Gnanendra](https://discuss.elastic.co/u/Gnanendra)\
**Post date:** [April 9, 2019, 6:06am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956/1 "2019-04-09T06:06:10Z")

</div>

Hi,  
I am marked indices read\_only and after apply force merge operation that same indices. i am getting below error. i am doing below steps. please help me.

Step1: GET my\_indices/\_settings

{

"my\_indices" : {

```
"settings" : {

  "index" : {

    "creation_date" : "1554723807184",

    "number_of_shards" : "1",

    "number_of_replicas" : "2",

    "uuid" : "s080nZ7nSKGSfLg_9_53rQ",

    "version" : {

      "created" : "6050499"

    },

    "provided_name" : "my_indices"

  }

}

```

}

}

Step2: PUT my\_indices/\_settings

{

"index": {

```
"blocks.read_only": true

```

}

}

{

"my\_indices" : {

```
"settings" : {

  "index" : {

    "number_of_shards" : "1",

    "blocks" : {

      "read_only" : "true"

    },

    "provided_name" : "my_indices",

    "creation_date" : "1554723807184",

    "number_of_replicas" : "2",

    "uuid" : "s080nZ7nSKGSfLg_9_53rQ",

    "version" : {

      "created" : "6050499"

    }

  }

}

```

}

}

Step3: POST /my\_indices/\_forcemerge?max\_num\_segments=1

"error": {

```
"root_cause": [

  {

    "type": "cluster_block_exception",

    "reason": "blocked by: [FORBIDDEN/5/index read-only (api)];"

  }

],

"type": "cluster_block_exception",

"reason": "blocked by: [FORBIDDEN/5/index read-only (api)];"

```

},

"status": 403

}

Thanks,  
gnanendra

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 9, 2019, 6:08am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956/2 "2019-04-09T06:08:23Z")

</div>

You need to run the merge before you set it as read only.

The whole idea of read only is that you cannot change it, on any level.

---

<div class="post-metadata">

**Author:** ![Gnanendra](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Gnanendra](https://discuss.elastic.co/u/Gnanendra)\
**Post date:** [April 9, 2019, 6:14am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956/3 "2019-04-09T06:14:01Z")

</div>

Hi warkolm,

but first i am changing indices read only after i apply force merge operation on that indices.

please refre this one:

Force merge should only be called against **read-only indices**. Running force merge against a read-write index can cause very large segments to be produced (\>5Gb per segment), and the merge policy will never consider it for merging again until it mostly consists of deleted docs. This can cause very large segments to remain in the shards.

please help me.

Thanks,  
gnanendra

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 9, 2019, 6:50am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956/4 "2019-04-09T06:50:44Z")

</div>

I think this is a bug in the docs. What it is trying to say is that you should only force merge on an index that you will never change in future: you must:

1. stop indexing to this index
2. force merge it
3. set `index.blocks.read_only: true`

The index is technically read-only as soon as you stop indexing into it, i.e. step 1, but you cannot apply the block until after step 2.

---

<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:** [May 7, 2019, 6:51am UTC](https://discuss.elastic.co/t/blocked-by-forbidden-5-index-read-only-api/175956/5 "2019-05-07T06:51:05Z")

</div>

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