ItsmeITItsmeIT
  • Linux
    • Debian
    • Ubuntu
  • PC/Windows
Reading: How to Install Elasticsearch on Ubuntu 22.04/24.04
Share
Notification Show More
Font ResizerAa
ItsmeITItsmeIT
Font ResizerAa
  • Categories
    • Linux
    • Debian
    • Ubuntu
    • PC/Windows
Have an existing account? Sign In
Follow US
© 2025 ItsmeIT. All rights reserved.

Home » Linux » Ubuntu » How to Install Elasticsearch on Ubuntu 22.04/24.04

How to Install Elasticsearch on Ubuntu 22.04/24.04

avatar
By
Loibv
avatar
ByLoibv
The ItsmeIT team – delivering cutting-edge updates, tech trends, and insider knowledge from the world of technology.
Follow:
Last updated: August 26, 2025

Elasticsearch is a powerful open-source search and analytics engine. It allows you to store, search, and analyze vast amounts of data quickly and almost in real time. I have personally tested Elasticsearch on Ubuntu 22.04/24.04 and found it to be very stable, especially when integrated with Magento 2. In this guide, I will share detailed steps so you can install and use it effectively.

Step 1: Install OpenJDK

To run Elasticsearch, you need to install OpenJDK. If you already have it installed, you can skip this step.

sudo apt install openjdk-11-jdk -y

Step 2: Add the Elasticsearch PGP Key

Elasticsearch Ubuntu packages are registered with PGP key D88E42B4, you can view at https://pgp.mit.edu with authentication key:

4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

Download and add the key with the following command:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

Download and add the key with the following command:

Next, add the Elasticsearch repository to /etc/apt/sources.list.d/elastic-7.x.list:

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

Step 3: Install from the APT Repository

You may need to install the apt-transport-https package before proceeding:

sudo apt-get install apt-transport-https

Step 4: Install Elasticsearch

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

Step 5: Configure Elasticsearch

Next, open the elasticsearch.yml file, find the network.host line, remove the # (uncomment it), and change the default IP 192.168.0.1 to localhost as follows:

sudo nano /etc/elasticsearch/elasticsearch.yml
Configure network.host in Elasticsearch
Configure network.host in Elasticsearch

Apply the Configuration

After making the changes, press Ctrl + X, then select Y to save the configuration and start Elasticsearch:

sudo systemctl start elasticsearch.service

To enable Elasticsearch to start automatically with Ubuntu, run:

sudo systemctl enable elasticsearch.service

If you only modified the configuration, you can reload the service without restarting:

sudo systemctl daemon-reload

Check Elasticsearch’s running status:

sudo systemctl status elasticsearch

Step 6: Verify Elasticsearch is Running

Since we configured network.host as localhost in Step 5, you can open a browser and access the following URL to check: http://localhost:9200

Check Elasticsearch running status
Check Elasticsearch running status in the browser

I always verify Elasticsearch using both a browser and a curl command to ensure it is functioning correctly. You can try both methods as follows:

curl -X GET http://localhost:9200
Check Elasticsearch running status using curl
Check Elasticsearch running status using curl

Troubleshooting Common Errors

Error 1: Elasticsearch Fails to Start

👉 Cause: Could be due to insufficient memory or incorrect Java installation.
👉 Solution: Check logs for specific errors:

sudo journalctl -u elasticsearch --no-pager | tail -50

If the error is Java-related, check the installed Java version:

java -version

If Java is not the correct version, reinstall it:

sudo apt install openjdk-11-jdk -y

Error 2: Permission Denied When Running Elasticsearch

👉 Cause: Elasticsearch runs under the elasticsearch user, but the data/log directories may lack proper permissions.
👉 Solution: Grant the necessary permissions:

sudo chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
sudo chown -R elasticsearch:elasticsearch /var/log/elasticsearch

Then restart Elasticsearch:

sudo systemctl restart elasticsearch

Error 3: Cannot Connect to Elasticsearch on Port 9200

👉 Cause: Elasticsearch may not be running or could be blocked by the firewall.
👉 Solution: Check the service status:

sudo systemctl status elasticsearch

If the service is not running, restart it:

sudo systemctl start elasticsearch

Additionally, check and configure the firewall:

sudo ufw allow 9200
sudo ufw enable

After completing these steps, you have successfully installed Elasticsearch 7 on Ubuntu. Continue exploring and leveraging Elasticsearch’s powerful search and analytics features!

Share This Article
Facebook Reddit Telegram Threads
avatar
ByLoibv
Follow:
The ItsmeIT team – delivering cutting-edge updates, tech trends, and insider knowledge from the world of technology.
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

Most Popular

install wordpress nginx
How to Install WordPress on Ubuntu 22.04/24.04 with Nginx, MariaDB, PHP8.2 (LEMP)
Scan Virus Ubuntu
3 Best Ways to Detect and Remove Malware on Ubuntu/Linux
boot virtualbox from usb
How to Boot from USB in VirtualBox on Ubuntu/Linux
Install SSL Localhost Ubuntu
How to Install SSL on Localhost in Ubuntu / Linux?
fix login error Gnome Online Accounts Ubuntu 22.04
How to Fix GNOME Online Accounts Login Issues on Ubuntu 22.04
Previous Next
ItsmeITItsmeIT
Follow US
© 2025 ItsmeIT. All Rights Reserved.
  • Privacy Policy
  • Terms of Service
Logo ItsmeIT logo
Welcome Back!

Sign in to your account

Continue with Google
Register   |Lost your password?