How to Check Your Elasticsearch Version from the Command Line

October 25, 2022 . 3 MIN READ

Introduction
When working with Elasticsearch to store and manage data, there may be times when you need to check which version of the software is running. Knowing the version can help determine whether an upgrade is required or ensure compatibility with other components in the Elastic Stack. Fortunately, Elasticsearch provides simple ways to retrieve this information. In this guide, you’ll learn two easy methods to check your Elasticsearch version directly from the command line.


Prerequisites
Before checking the Elasticsearch version, make sure a few basic requirements are met:

  • Elasticsearch must be installed and running on your system.

To confirm that Elasticsearch is active, run the following command in your terminal:

curl http://localhost:9200/_cluster/health?pretty

If Elasticsearch is running properly, the command will return details about your cluster and its health status. If no output appears or the response is unexpected, you may need to restart the Elasticsearch service.

You should also have basic familiarity with command-line tools and the curl utility. The curl command allows you to send HTTP requests from the terminal to communicate with servers. In this tutorial, it will be used to interact with Elasticsearch.


Ways to Check Your Elasticsearch Version

Option 1: Check the Version Using Curl

One of the simplest ways to identify your Elasticsearch version is by sending an HTTP request to the server using curl. If Elasticsearch is running locally on the default port, execute the following command:

curl -XGET ‘http://localhost:9200’

This command sends a request to the Elasticsearch server and returns information about the cluster, including the installed version.

If Elasticsearch is running on another server, replace localhost with your server’s domain or IP address, for example:

http://YOURDOMAIN.com:9200

The response will include several details about your Elasticsearch instance. Among them, you will see the version number listed inside the version section. For example, the output might show that the installed version is 6.6.1.

Note: If the version displayed in the output does not match the version you expect, it may indicate that multiple Elasticsearch installations exist on your system.


Option 2: Check the Version Using the Version Flag

Another way to view the Elasticsearch version is by using the --version flag when running the Elasticsearch binary. Instead of starting the service normally and scanning through logs, this command displays the version information directly.

Example command:

bin/elasticsearch –version

The output will display details such as the Elasticsearch version, build information, and the Java Virtual Machine (JVM) version being used. For instance, it might show something like:

Version: 6.6.1, Build: default/tar/1fd8f69/2019-02-13T17:10:04.160291Z, JVM: 11.0.2

This confirms the exact version of Elasticsearch installed on your system.


Conclusion
Checking your Elasticsearch version is an important step when maintaining your search infrastructure. Whether you’re troubleshooting issues, verifying compatibility with other Elastic Stack components, or planning an upgrade, knowing the installed version is essential. As demonstrated above, you can quickly retrieve this information either by sending a curl request to your Elasticsearch server or by using the --version command from the terminal. Both methods are simple and require only basic command-line knowledge.

Reference:

https://kb.objectrocket.com/elasticsearch/how-to-check-your-elasticsearch-version-from-the-command-line

Leave a Reply

Your email address will not be published. Required fields are marked *