Shards not assigned when creating an index

Hi all.

I am having trouble creating a new index: elastic search assigns 3 shards and leaves 2 unassigned.

It is installed as a 4-node cluster in amazon, almost out of the box. The cluster has 2 nodes in 2 different availability zones. It is configured with 5 shards and 3 replicas. I create the index from a java client and start indexing documents immediately. In kopf, the cluster appears red, with 2 master shards unassigned. The last 2 times I tried, it successfully created shards 1, 2 and 3, but failed in shards 0 and 4. We had to manually assign the shards to a node.

I enabled the debug logs, but no exception there. It looks like the index is created, closed and reopened. In the logs I found:

state: [RECOVERING]->[CLOSED], reason [removing shard (index is closed)]

for the failing shards, and:

state: [STARTED]->[CLOSED], reason [removing shard (index is closed)]

for the working shards.

Any ideas?

Thanks a lot.

Lack of disk space if usually the primary reason for this.

Thanks for your answer.

I checked that the first time it failed, but all nodes had plenty of space.