Elasticsearch is an open-source distributed full-text search and analytics engine. It supports RESTful operations and allows you to store, search, and analyze big volumes of data in real-time. Elasticsearch is one of the most popular search engines powering applications that have complex search requirements such as big e-commerce stores and analytic applications.

This guide explains how to install Elasticsearch on Ubuntu 20.04.

Installing Elasticsearch

Installing Elasticsearch on Ubuntu is fairly straightforward. We’ll enable the Elasticsearch repository, import the repository GPG key, and install the Elasticsearch server.

The Elasticsearch package ships with a bundled version of OpenJDK, so you do not have to install Java.

First, update the packages index and install the dependencies necessary to add a new HTTPS repository :

sudo apt updatesudo apt install apt-transport-https ca-certificates wgetCopyCopy

Import the repository’s GPG key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

The command above should output OK, which means that the key has been successfully imported, and packages from this repository will be considered trusted.

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

sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'

If you want to install a previous version of Elasticsearch, change 7.x in the command above with the version you need.

Once the repository is enabled, install Elasticsearch by typing:

sudo apt updatesudo apt install elasticsearchCopyCopy

Elasticsearch service will not start automatically after the installation process is complete. To start the service and enable the service run:

sudo systemctl enable --now elasticsearch.service

To verify that Elasticsearch is running, use curl to send an HTTP request to port 9200 on localhost:

curl -X GET "localhost:9200/"

You should see something similar to this:

  "name" : "vagrant",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "IJqDxPfXSrmFQ27KbXbRIg",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "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"

It may take 5-10 seconds for the service to start. If you see curl: (7) Failed to connect to localhost port 9200: Connection refused, wait for a few seconds and try again.

To view the messages logged by the Elasticsearch service, use the following command:

sudo journalctl -u elasticsearch

That’s it. Elasticsearch has been installed on your Ubuntu server.

Configuring Elasticsearch

Elasticsearch data is stored in the /var/lib/elasticsearch directory. Configuration files are located in /etc/elasticsearch and Java start-up options can be configured in the /etc/default/elasticsearch file.https://a4861147f6879183d9eeedd151cf9430.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.htmlBy default, Elasticsearch is configured to listen on localhost only. If the client connecting to the database is also running on the same host and you are setting up a single node cluster, you don’t need to change the default configuration file.

Remote Access

Out of box Elasticsearch, does not implement authentication, so it can be accessed by anyone who can access the HTTP API.

To allow remote access to your Elasticsearch server, you will need to configure your firewall and open TCP port 6379.https://googleads.g.doubleclick.net/pagead/ads?us_privacy=1—&client=ca-pub-9439755881064125&output=html&h=15&slotname=2822423476&adk=2131362362&adf=3877921081&pi=t.ma~as.2822423476&w=728&lmt=1660940127&psa=0&channel=7012520740&url=https%3A%2F%2Flinuxize.com%2Fpost%2Fhow-to-install-elasticsearch-on-ubuntu-20-04%2F&wgl=1&adsid=ChEI8NKMmAYQhcumvd770MuHARI9AA2R2Ehs06ZSvkps01o2NTmP3NUvymbSic9RqHeevcoalHgl-oaw-GSMlOK8a3heifHx8X4vx70gatEBkQ&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTA0LjAuNTExMi4xMDEiLFtdLGZhbHNlLG51bGwsIjY0IixbWyJDaHJvbWl1bSIsIjEwNC4wLjUxMTIuMTAxIl0sWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiR29vZ2xlIENocm9tZSIsIjEwNC4wLjUxMTIuMTAxIl1dLGZhbHNlXQ..&dt=1661152381549&bpp=18&bdt=231&idt=212&shv=r20220817&mjsv=m202208170101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D64b3057c1daf8fae%3AT%3D1661152382%3AS%3DALNI_MYnh4EjOa1yu3_F_oRFMpJx978wfQ&gpic=UID%3D000008dfda894881%3AT%3D1661152382%3ART%3D1661152382%3AS%3DALNI_MbJ4A7ONocAb6BLa3bFh3W5edCQfQ&correlator=4255820459554&frm=20&pv=2&ga_vid=76712873.1661152382&ga_sid=1661152382&ga_hid=1903009180&ga_fc=1&u_tz=480&u_his=2&u_h=864&u_w=1536&u_ah=824&u_aw=1536&u_cd=24&u_sd=1.25&dmc=8&adx=384&ady=4863&biw=1519&bih=722&scr_x=0&scr_y=1990&eid=44759875%2C44759926%2C44759837%2C31068957%2C31069049%2C21065725&oid=2&pvsid=3565128663499727&tmod=1128673057&uas=0&nvt=1&ref=https%3A%2F%2Fblog.security-warehouse.com%2F&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C824%2C1536%2C722&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&jar=2022-08-22-06&ifi=1&uci=a!1&btvi=1&fsb=1&xpc=NNJta43TFG&p=https%3A//linuxize.com&dtd=3863

Typically, you would want to allow access to the Redis server only from a specific IP address or IP range. For example, to allow connections only from the subnet, you would run the following command:

sudo ufw allow proto tcp from to any port 6379

Once the firewall is configured, the next step is to edit the Elasticsearch configuration and allow Elasticsearch to listen for external connections.

To do so, open the elasticsearch.yml configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Search for the line that contains network.host, uncomment it, and change the value to



If you have multiple network interfaces on your machine, specify the interface IP address to force Elasticsearch to listen only to the given interface.

Restart the Elasticsearch service for the changes to take effect:

sudo systemctl restart elasticsearch

That’s it. You can now connect to the Elasticsearch server from your remote location.


We’ve shown you how to install Elasticsearch on Ubuntu 20.04.

To learn more about Elasticsearch, visit the official documentation page.

If you hit a problem or have feedback, leave a comment below.