How to fix ElasticSearch [FORBIDDEN/12/index read-only / allow delete (api)]
If you try to index a document in ElasticSearch and you see an error message like this:
elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, 'cluster_block_exception', 'blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];')
you can unlock writes to your cluster (all indexes) using
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
(thanks to Imran273 on StackOverflow for the original solution)
Note however that often there’s an underlying reason that caused ElasticSearch to lock writes to the index. Most often it is caused by exceeding the disk watermark / quota. SeeĀ How to disable ElasticSearch disk quota / watermark for details on how to work around that.