I have Ubuntu 16.04 LTS on virtual box and I'd like to install elasticsearch in order to use it with Ruby on Rails. I've done a search on google on how to do the installation, but I have found mutiple guides that have a few differences which got me a little bit confused, for instance:

Installing elasticsearch on Ubuntu 16.04

Digital Ocean: Install and Configure Elasticsearch on Ubuntu 16.04

(see @ Prerequisites)

How should I install elasticsearch safely, without messing up my development environment?

  • If my solution worked for your problem, could you please accept the answer? In that way people know if the problem is solved. Thank you – SebastienPattyn Oct 20 '17 at 14:31
  • 1
    Sorry I missed you – ltdev Oct 20 '17 at 14:43

Elastic has their own guide to install elasticsearch with Debian packages. you can find it on their website.


I used this one and now everything works like a charm.

Elasticsearch requires Java 8 or later:

$ sudo apt-get install openjdk-8-jdk
$ java -version
openjdk version "1.8.0_111"

Install Elasticsearch

$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ sudo apt-get install apt-transport-https
$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch

some remarks (from elastic website):

  • Do not use add-apt-repository as it will add a deb-src entry as well, but we do not provide a source package. If you have added the deb-src entry, you will see an error like the following:
Unable to find expected entry 'main/source/Sources' in Release file
Wrong sources.list entry or malformed file)

=> Delete the deb-src entry from the /etc/apt/sources.list file and the installation should work as expected.

  • If two entries exist for the same Elasticsearch repository, you will see an error like this during apt-get update:

Duplicate sources.list entry https://artifacts.elastic.co/packages/5.x/apt/ ...`

=> Examine /etc/apt/sources.list.d/elasticsearch-5.x.list for the duplicate entry or locate the duplicate entry amongst the files in /etc/apt/sources.list.d/ and the /etc/apt/sources.list file

| improve this answer | |

For very basic installation of ElasticSearch 1.x or 2.x on Ubuntu 16.04

(the same goes for Ubuntu 14.04) do the next few steps on fresh install Ubuntu:

  1. sudo apt-get update

  2. sudo apt-get upgrade

  3. sudo add-apt-repository ppa:webupd8team/java

  4. sudo apt-get update

  5. sudo apt-get install oracle-java8-installer

  6. java -version

//For 2.x; elasticsearch 2.4.0

  1. wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.4.0/elasticsearch-2.4.0.deb

  2. sudo dpkg -i elasticsearch-2.4.0.deb

  3. service elasticsearch status

  4. sudo apt-get install -y curl lynx links

  5. lynx http : // localhost : 9200


  1. curl -X GET 'http : // localhost:9200'
| improve this answer | |

Installing ElasticSearch 6.8.6 on Ubuntu 16

The latest version at the time of writing was 7 but we needed version 6 for compatibility reasons so using the typical apt-get package manager wouldn't work. Instead we opted to install the package directly.

  1. Download and install the debian package for version 6.8.6:

    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.6.deb
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.6.deb.sha512
    shasum -a 512 -c elasticsearch-6.8.6.deb.sha512 
    sudo dpkg -i elasticsearch-6.8.6.deb
  2. Setup elasticsearch to start automatically on boot.

    sudo /bin/systemctl daemon-reload
    sudo /bin/systemctl enable elasticsearch.service
  3. Start the elasticsearch service.

    sudo systemctl start elasticsearch.service
  4. Confirm elasticsearch is running:

    $ curl -X GET "localhost:9200/?pretty"
      "name" : "dfdnndd",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "abcdadsf123234234",
      "version" : {
        "number" : "6.8.6",
        "build_flavor" : "default",
        "build_type" : "deb",
        "build_hash" : "3d9f765",
        "build_date" : "2019-12-13T17:11:52.013738Z",
        "build_snapshot" : false,
        "lucene_version" : "7.7.2",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      "tagline" : "You Know, for Search"

    NOTE: Sometimes it takes a few seconds to spin up.

  5. Configure as necessary:

    vi /etc/elasticsearch/elasticsearch.yml

    For example, uncomment this line, #network.host: localhost, and replace localhost with your server's IP address so it looks someting like this: network.host:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.