Removing a node from an Elasticsearch cluster

Explaining how to remove a node from an Elasticsearch cluster.

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. If you want to learn about the concept of Elasticsearch nodes and the types of roles, check out this guide.

Steps to safely remove a node from an Elasticsearch cluster

1. Stop indexing and perform a synced flush (optional)

First, if you can afford to stop indexing for a short period, it is recommended to perform a synced flush. This operation helps speed up the recovery process when the cluster restarts after a node is removed. 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.

2. Retrieve the node name

After performing a sync flush, you will need to know the node name in order to remove it from the cluster. 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.

3. Remove the node from the cluster

After you’ve determined the node name, you can remove the node from the cluster. To remove the node from the cluster, 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.

4. Stop the Elasticsearch process on the node

After all shards have relocated to the other nodes, 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

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” (meaning that all shards are properly allocated) and the number of nodes in the cluster has been reduced by one.

Elastic Cloud Serverless

Another option to avoid worrying about nodes is using Elastic Cloud Serverless. In this fully managed solution, Elastic takes care of the underlying architecture of your cluster, meaning you don’t need to worry about nodes, shards, or scaling, everything happens automagically.

Conclusion

In conclusion, removing a node from an Elasticsearch cluster involves disabling shard allocation to that node, 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. If you are looking for a managed solution, you could use Elastic Cloud Serverless.

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

Building an MCP server with Elasticsearch for real health data

June 26, 2025

Building an MCP server with Elasticsearch for real health data

Learn learn how to build an MCP server using FastMCP and Elasticsearch to manage and search data.

Ruby scripting in Logstash

June 24, 2025

Ruby scripting in Logstash

Learn about the Logstash Ruby filter plugin for advanced data transformation in your Logstash pipeline.

ECK made simple: Deploying Elasticsearch on GCP GKE Autopilot

June 19, 2025

ECK made simple: Deploying Elasticsearch on GCP GKE Autopilot

Learn how to deploy an Elasticsearch cluster on GCP using GKE Autopilot and ECK.

Elasticsearch open inference API adds support for IBM watsonx.ai rerank models

Elasticsearch open inference API adds support for IBM watsonx.ai rerank models

Exploring how to use IBM watsonx™ reranking when building search experiences in the Elasticsearch vector database.

Using Azure LLM Functions with Elasticsearch for smarter query experiences

June 13, 2025

Using Azure LLM Functions with Elasticsearch for smarter query experiences

Try out the example real estate search app that uses Azure Gen AI LLM Functions with Elasticsearch to provide flexible hybrid search results. See step-by-step how to configure and run the example app in GitHub Codespaces.

Ready to build state of the art search experiences?

Sufficiently advanced search isn’t achieved with the efforts of one. Elasticsearch is powered by data scientists, ML ops, engineers, and many more who are just as passionate about search as your are. Let’s connect and work together to build the magical search experience that will get you the results you want.

Try it yourself