Sep 26, 2023 5 min read

How to Install Elasticsearch on Debian 12

Install and use Monit on Ubuntu 20.04 with our step-by-step tutorial. Elasticsearch is a scalable open-source search and analytics engine.

Install Elasticsearch on Debian 12
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Elasticsearch on Debian 12, let's briefly understand – What is Elasticsearch?

Elasticsearch is a powerful and scalable open-source search and analytics engine. It is designed to handle vast amounts of data in real-time, making it ideal for businesses requiring quick and precise search functionality.

With its distributed architecture and robust features, Elasticsearch enables efficient storage, retrieval, and analysis of data, providing valuable insights. Whether used for log analysis, full-text search, or data exploration, Elasticsearch simplifies data management and enhances search capabilities for businesses of all sizes.

Elasticsearch was first introduced by Shay Banon as Compass in 2004. It was then made available as Elasticsearch in 2010. The Lucene library, which is used for RESTful tasks like finding, storing, and analysing enormous amounts of data, is a prerequisite for the open-source search engine Elasticsearch.

Additionally, it supports the schemaless JSON documents, sometimes referred to as NoSQL databases, together with the full-text engine and HTTP web interface.

In this tutorial, you will install Elasticsearch on Debian 12. We will also address a few FAQs on how to install Elasticsearch on Debian 12.

Advantages of Elasticsearch

  1. Scalability: Elasticsearch is highly scalable, allowing you to effortlessly handle large volumes of data.
  2. Speed: With its inverted index architecture and distributed processing, Elasticsearch ensures fast search and retrieval of information.
  3. Full-text search capability: It supports complex queries and offers linguistic analysis, making it ideal for search-intensive applications.
  4. Real-time data analytics: Elasticsearch's ability to provide real-time analysis and visualization of data enables actionable insights.
  5. Easy integration: With a rich ecosystem and extensive APIs, Elasticsearch seamlessly integrates with various tools, making it versatile and developer-friendly.

How to install Elasticsearch on Debian 12

It is advised to update all of Debian's packages before beginning installation by running the command:

sudo apt update

One package needs to be upgraded, therefore we'll do that by running the following command:

sudo apt upgrade -y

Install some required packages

sudo apt install gnupg wget curl systemctl -y

Now that all the packages are updated, we can start the Elasticsearch installation process. Elastic search can be installed on Debian 12 using one of two methods:

  • through the repository's Debian 12 import of the GPG key.
  • directly from the Elasticsearch official website.

Through the repository's Debian 12 import of the GPG key

Using the wget command, we can import Elasticsearch's GPG key from the company's official website and then install it on Debian 12:

wget -qO - | sudo apt-key add -

Once the GPG key has been imported successfully, OK will be shown in the output. Use the following command to import the Elasticsearch source repository into the Debian 12 repository:

echo "deb stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

Update it once more after the GPG key and the source repository have been added to the Debian 12 repository.

sudo apt update

After the update, use the following command to start the Elasticsearch installation:

sudo apt install elasticsearch 

Elasticsearch has been set up.

Directly from the Elasticsearch official website

Instead of importing Elasticsearch's key into the Debian 12 repository, we may also install it straight from the company's website. To accomplish this, we will first use the following command to submit an HTTP request to the Elasticsearch server in order to establish a connection:


To install the package Elasticsearch on Debian 12, now run the command below:

sudo apt install ./elasticsearch-7.15.1-amd64.deb

The installation will begin and prompt you to continue. Type "y" and wait until it completes, which will take a little while.

After the installation is complete, we will turn on the Elasticsearch service. On Debian 12, the Elasticsearch service is disabled by default. To enable it, use the systemctl command as follows:

sudo systemctl enable elasticsearch.service --now 

Now, use the systemctl command to launch the Elasticsearch service:

sudo systemctl start elasticsearch.service 

Run the following command to verify Elasticsearch's service status:

sudo systemctl status elasticsearch.service

After the Elasticsearch service has successfully run, we will adjust its firewall settings by opening port 9200 using the ufw command:

sudo ufw allow 9200 

By using the following command, we may obtain information about the Elasticsearch installation version:

curl -X GET "http://localhost:9200/?pretty"

  "name" : "91e3423a4033",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "jmgn0PuITe6ikkFE8MjRlA",
  "version" : {
    "number" : "7.17.11",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "eeedb98c60326ea3d46caef960fb4c77958fb885",
    "build_date" : "2023-06-23T05:33:12.261262042Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

Now, if we want to uninstall the Elasticsearch package from Debian 12, we will use the command that follows:

sudo apt remove elasticsearch -y

The removal of Elasticsearch was successful.

FAQs to Install Elasticsearch on Debian 12

Where can I find the Elasticsearch configuration files? 

The Elasticsearch configuration files can be found in the /etc/elasticsearch directory on your Debian 12 system.

How can I change the default Elasticsearch configuration?

To modify the Elasticsearch configuration, open the /etc/elasticsearch/elasticsearch.yml file and make the necessary changes. Remember to restart the Elasticsearch service afterward.

How do I check the status of Elasticsearch service? 

You can check the status of the Elasticsearch service by running the command: sudo systemctl status elasticsearch.

Can I install multiple instances of Elasticsearch on the same Debian 12 machine? 

Yes, it is possible to install and configure multiple instances of Elasticsearch on the same Debian 12 machine. Each instance requires a unique configuration and port assignment.

How do I access the Elasticsearch REST API? 

The Elasticsearch REST API can be accessed using HTTP requests on port 9200. For example, curl -XGET 'localhost:9200' will give you information about your Elasticsearch cluster.

How can I secure my Elasticsearch installation? 

Elasticsearch can be secured by configuring access controls, enabling SSL/TLS encryption, and implementing authentication mechanisms such as X-Pack or Search Guard.

Where can I find Elasticsearch logs?

Elasticsearch logs can be found in the /var/log/elasticsearch directory on your Debian 12 system. The main log file is called elasticsearch.log.


Elasticsearch is a JSON-document-based search engine that searches and retrieves data using the Lucene library. It can be installed in practically all Linux distributions, but this tutorial will discuss how to install Elasticsearch on the most recent Debian version using both of these methods—directly from the website and using the repository in detail.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.