What's Actually Happening
Your Elasticsearch index is in readonly mode, preventing all write operations. Documents cannot be indexed, updated, or deleted.
The Error You'll See
```bash $ curl -XPOST 'localhost:9200/myindex/_doc' -d '{"test":"data"}'
{ "error": { "type": "index_read_only_exception", "reason": "index read-only / allow delete (api)" } } ```
Why This Happens
- 1.Disk flood stage - Disk usage > 95%
- 2.Flood stage triggered - Automatic protection activated
- 3.Manual setting - Index set to readonly
- 4.Allocation failed - Shard cannot be allocated
Step 1: Check Index Settings
```bash # Check index settings: curl -XGET 'localhost:9200/myindex/_settings?pretty'
# Check readonly flag: curl -XGET 'localhost:9200/myindex/_settings?pretty' | grep read_only ```
Step 2: Check Disk Space
```bash # Check disk usage: curl -XGET 'localhost:9200/_cat/allocation?v'
# Check flood stage watermark: curl -XGET 'localhost:9200/_cluster/settings?pretty' | grep flood ```
Step 3: Clear Readonly Flag
```bash # Clear readonly for specific index: curl -XPUT 'localhost:9200/myindex/_settings' -d '{ "index.blocks.read_only_allow_delete": null }'
# Clear for all indices: curl -XPUT 'localhost:9200/_all/_settings' -d '{ "index.blocks.read_only_allow_delete": null }' ```
Elasticsearch Index Readonly Checklist
| Check | Command | Expected |
|---|---|---|
| Disk usage | _cat/allocation | < 95% |
| Readonly flag | _settings | null |
| Write allowed | test write | Success |
Verify the Fix
```bash # Test write: curl -XPOST 'localhost:9200/myindex/_doc' -d '{"test":"data"}' # Output: created: true
# Check settings: curl -XGET 'localhost:9200/myindex/_settings?pretty' | grep read_only # Output: No readonly setting ```
Related Issues
- [Fix Elasticsearch Cluster Red Status](/articles/fix-elasticsearch-cluster-red-status)
- [Fix Elasticsearch Shard Allocation Failed](/articles/fix-elasticsearch-shard-allocation-failed)