Install ElasticSearch 7 on Ubuntu 20.04

Upasana | July 11, 2020 | 3 min read | 385 views

In this tutorial, we will show you how to install single node cluster of ElasticSearch 7.7 on Ubuntu 20.04 LTS and manage it with systemctl. The same instructions shall apply to Ubuntu 18.04/16.04 LTS as well.

Elasticsearch is one of the most popular open-source distributed full-text search & analytics engine developed by


You need to be logged into your Ubuntu system with a user account that has sudo privileges for installing new packages.

Install Elasticsearch

We will use Debian package from the official Elasticsearch repository to install latest version of elasticsearch.

At the time of writing this article, v7.7.0 is the latest version of Elasticsearch. You can check the latest version of Elasticsearch here.

Elasticsearch includes a bundled version of OpenJDK so you do not need to install Java separately to make it work.

First of all, lets update packages index on your system and install apt-transport-https package which will enable us to access a repository over HTTPS:

$ sudo apt update
$ sudo apt-get install apt-transport-https

Import PGP Key

Now we will add the Elasticsearch repository. First we will download and install the PGP Key using wget command.

$ wget -qO - | sudo apt-key add -

This will ensure that packages from Elasticsearch repository will be considered trusted.

Next is to add the Elasticsearch repository to the system by issuing:

$ sudo sh -c 'echo "deb stable main" > /etc/apt/sources.list.d/elastic-7.x.list'

Install Elasticsearch Debian package

Update the apt packages and install the Elasticsearch by issuing the following command:

$ sudo apt-get update && sudo apt-get install elasticsearch

Now our Elasticsearch service is installed.

Manage service startup

If you want to start Elasticsearch at system startup, you need to run the below command:

$ sudo systemctl daemon-reload
$ sudo systemctl enable elasticsearch.service
$ sudo systemctl start elasticsearch.service
$ sudo systemctl status elasticsearch.service

You can always check logs:

$ tail -200f /var/log/elasticsearch/elasticsearch.log

Verify the status

You can verify the installation by running the following curl command.

$ curl -X GET "localhost:9200/"

output should be something like this:

  "name" : "shunya-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "xmq_b5vaReaaBjPbrcDXjA",
  "version" : {
    "number" : "7.7.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf",
    "build_date" : "2020-05-12T02:01:37.602180Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

Check cluster settings:

$ curl -X GET "localhost:9200/_cluster/settings?pretty"
  "persistent" : { },
  "transient" : { }

Configure Remote Access

By default, elasticsearch listens on localhost, that means you cannot access the service from remote machine. To enable remote access, you will have to update the configuration.

$ sudo vi /etc/elasticsearch/elasticsearch.yml

Search for, uncomment it and change its value to Also if you running a single node cluster, you need to set value for discovery.seed_hosts.

discovery.seed_hosts: [""]

After making this change, restart the elasticsearch service.

$ sudo systemctl restart elasticsearch

Uninstall Elasticsearch completely

You can remove elasticsearch package along with its configuration and data/node folders from the system using remove and purge command respectively.

Uninstall elasticsearch package

To uninstall elasticsearch package from Ubuntu 20.04 LTS, execute the below command on terminal:

$ sudo apt-get remove elasticsearch

Delete configuration and data

If you wish to delete configuration and data files of elasticsearch installation on Ubuntu system, run the below command:

$ sudo apt-get purge elasticsearch

That’s all.

Top articles in this category:
  1. Install Cassandra 4 on Ubuntu 20.04
  2. Install & configure Redis on Ubuntu
  3. Upgrade Jenkins on Ubuntu 18.04 LTS
  4. Install OpenJDK 11 on Ubuntu 18.04 LTS
  5. Install RabbitMQ and Erlang 23 on Ubuntu 20
  6. MySql 8 installation on Ubuntu 20
  7. Upgrade MySQL from 5.7 to 8 on Ubuntu 18.04

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.