When managing an Elasticsearch cluster, there may be situations where you need to remove a node from the cluster. This could be due to hardware issues, maintenance, or scaling down the cluster. In this article, we will discuss the steps to safely remove a node from an Elasticsearch cluster without causing any data loss or impacting the cluster’s performance.
Steps to safely remove a node from an Elasticsearch cluster
Step 1: Stop indexing and perform a synced flush (optional)
If you can afford to stop indexing for a short period, it is recommended to perform a synced flush. This operation helps to speed up the recovery process when the cluster restarts after the node removal. To perform a synced flush, execute the following command:
POST _flush/synced
Note that this step is optional and can be skipped if stopping indexing is not feasible.
Step 2: Retrieve the node name
To remove a node from the cluster, you need to know its node name. You can retrieve the node name by executing the following command:
GET _cat/nodes?v
This command will return a list of nodes in the cluster along with their node names. Identify the node you want to remove and note down its node name.
Step 3: Remove the node from the cluster
To remove the node from the cluster, you need to update the cluster settings to exclude the node using its node name. Execute the following command, replacing <node_name>
with the node name you retrieved in the previous step:
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.exclude._name": "<node_name>"
}
}
This command will instruct Elasticsearch to move all shards from the specified node to other nodes in the cluster. You can monitor the progress of shard relocation by executing the following command:
GET _cat/recovery?v&active_only=true
Wait for the shard relocation process to complete before proceeding to the next step.
Step 4: Stop the Elasticsearch process on the node
After enabling shard allocation, you can safely stop the Elasticsearch process on the node you want to remove. Depending on your installation method and operating system, the command to stop Elasticsearch may vary. For example, if you are using systemd on a Linux system, you can execute the following command:
sudo systemctl stop elasticsearch
Step 5: Verify the cluster health
Finally, verify the health of the cluster by executing the following command:
GET _cluster/health
Ensure that the cluster status is “green” and the number of nodes in the cluster has been reduced by one.
Conclusion
In conclusion, removing a node from an Elasticsearch cluster involves disabling shard allocation, optionally performing a synced flush, excluding the node from the cluster, and stopping the Elasticsearch process on the node. By following these steps, you can safely remove a node without impacting the cluster’s performance or causing data loss.
Ready to try this out on your own? Start a free trial.
Want to get Elastic certified? Find out when the next Elasticsearch Engineer training is running!
Related content

April 30, 2025
Elasticsearch search by two fields
Exploring techniques for searching by two fields, including multi-match queries, bool queries, and query-time field boosting.

May 7, 2025
Understanding Elasticsearch scoring and the Explain API
Diving into the scoring mechanism of Elasticsearch and exploring the Explain API.

May 9, 2025
Joining two indexes in Elasticsearch
Explaining how to use the terms query and the enrich processor for joining two indexes in Elasticsearch.

May 1, 2025
RAG and the value of grounding
Learn about RAG, grounding and how to reduce hallucinations by connecting an LLM to your documents.

April 29, 2025
RAG without “AG”?
Learn how to leverage semantic search and ELSER to build a powerful and visually appealing Q&A experience, without using LLMs.