Identifying the elected master node shows which Elasticsearch node is currently publishing cluster-state changes. Operators use this check during rolling restarts, node-loss incidents, and shard allocation reviews because a missing or frequently changing master can delay metadata updates, node joins, and management API responses.
The _cat/master endpoint returns the elected node ID, host, IP address, and node name in a compact table for terminal checks. The _cat/nodes endpoint can then show the same node with * in the master column and expose whether each node is master-eligible through the compact node.role flags.
Run the request against an Elasticsearch HTTP endpoint that belongs to the cluster being inspected. Secured deployments usually require HTTPS, authentication, and a trusted CA, while the cluster-state API should stay a narrow diagnostic cross-check because Elastic warns that repeated broad cluster-state requests can stress larger clusters.
Steps to identify the elected master node in Elasticsearch:
- Query the elected master node from an Elasticsearch HTTP endpoint.
$ curl -sS --fail "http://localhost:9200/_cat/master?v&h=id,host,ip,node" id host ip node JndZsMgTSmukbYqEPosNHg 192.0.2.40 192.0.2.40 es-master-01
The request needs the monitor cluster privilege. On secured clusters, switch to the cluster's https:// endpoint and add the CA trust plus authentication method already used by operators.
A 401 or 403 response indicates missing credentials or insufficient privilege, while 503 or master_not_discovered_exception indicates the cluster does not currently have an elected master.
- Cross-check the same node against the cluster node list.
$ curl -sS --fail "http://localhost:9200/_cat/nodes?v&full_id=true&h=id,name,ip,node.role,master" id name ip node.role master JndZsMgTSmukbYqEPosNHg es-master-01 192.0.2.40 cdfhilmrstw * R7lPvJ2vTMevQW9ydT8wUQ es-data-01 192.0.2.41 cdfhilmrstw - Nw2sZx43QZe3nG5kY9zK7w es-data-02 192.0.2.42 cdfhilmrstw -
The master column shows * on the elected master and - on other joined nodes. The node.role column includes m on master-eligible nodes and v on voting-only nodes, which can vote but cannot become the elected master.
- Confirm the elected node ID from cluster state only when a JSON cross-check is needed.
$ curl -sS --fail "http://localhost:9200/_cluster/state/master_node?filter_path=cluster_name,master_node&pretty" { "cluster_name" : "search-cluster", "master_node" : "JndZsMgTSmukbYqEPosNHg" }Using filter_path=cluster_name,master_node keeps the diagnostic response narrow. Elastic documents the cluster-state API as an internal diagnostic surface, so do not use it as a frequent monitoring poll.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.