Error: redis cluster node is not empty

What's Causing This Error

The error 'redis cluster node is not empty' signifies that a Redis node currently holds data, and therefore, it cannot be used to create or join a cluster. This usually occurs when you try to form a cluster with nodes that have been used before and still contain key-value pairs.

Using existing nodes with data for cluster formation can lead to inconsistencies in data distribution across the entire cluster. The Redis clustering algorithm presumes that all joining nodes are initially empty to avoid any complications during the hash slot allocation and rebalancing processes. Thus, if a node contains data, the operation will fail, causing this error.

Solution - Here's How To Resolve It

To solve the 'redis cluster node is not empty' issue, you need to clear the data from the node before using it in a cluster formation process. This can be done in two ways:

  1. Flushing Data: Use the FLUSHALL command to remove all keys from the database of the node or nodes causing the trouble. Be cautious while using this command as it will permanently delete all data present on the node.
redis-cli -h hostname -p port FLUSHALL
  1. Reinitiate the Node: If you want to ensure no residual settings or data persist, you can fully reinitialize the node. Stop the Redis server, delete the dump files (dump.rdb, nodes.conf, etc.) manually, and then restart the server.

After you've cleared data from the node, you should be able to add it to your cluster without encountering the 'redis cluster node is not empty' error.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.