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

Introducing the ES|QL query builder for the Python Elasticsearch Client

September 9, 2025

Introducing the ES|QL query builder for the Python Elasticsearch Client

Learn how to use the ES|QL query builder, a new Python Elasticsearch client feature that makes it easier to construct ES|QL queries using a familiar Python syntax.

Transforming data interaction: Deploying Elastic’s MCP server on Amazon Bedrock AgentCore Runtime for crafting agentic AI applications

September 4, 2025

Transforming data interaction: Deploying Elastic’s MCP server on Amazon Bedrock AgentCore Runtime for crafting agentic AI applications

Transform complex database queries into simple conversations by deploying Elastic's search capabilities on Amazon Bedrock AgentCore Runtime platform.

Running cloud-native Elasticsearch with ECK

Running cloud-native Elasticsearch with ECK

Learn how to provision a GKE cluster with Terraform and run the Elastic Stack on Kubernetes using ECK.

Using UBI in Elasticsearch: Creating an app with UBI and search-ui

Using UBI in Elasticsearch: Creating an app with UBI and search-ui

Learn how to use UBI in Elasticsearch through a practical example. We’ll be creating an application that produces UBI events on search and click results.

Using ES|QL COMPLETION + an LLM to write a Chuck Norris fact generator in 5 minutes

August 28, 2025

Using ES|QL COMPLETION + an LLM to write a Chuck Norris fact generator in 5 minutes

Discover how to use the ES|QL COMPLETION command to turn your Elasticsearch data into creative output using an LLM in just a few lines of code.

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