How to Install Elasticsearch on Ubuntu 24.04 LTS
Step-by-step guide to install Elasticsearch on Ubuntu 24.04 LTS using the official Elastic 8.x repository, JVM heap tuning, and TLS security.

5 min read
Step-by-step guide to install Elasticsearch on Ubuntu 24.04 LTS using the official Elastic 8.x repository, JVM heap tuning, and TLS security.
- Prerequisites and Supported Releases
- Step 1: Installing Required Dependencies and Transport Packages
- Step 2: Importing the Official Elastic GPG Public Key
Log analytics platforms, full-text search engines, and real-time observability pipelines rely heavily on fast distributed inverted index engines. When you install elasticsearch on ubuntu 24.04, you deploy the heart of the Elastic Stack, capable of storing structured and unstructured data, performing complex aggregations, and executing semantic searches at massive scale.
Modern Elasticsearch (version 8.x) bundles its own optimized Java Virtual Machine (OpenJDK) and enforces security by default—including TLS/SSL transport encryption, HTTPS REST endpoints, and role-based user authentication. This step-by-step guide walks you through repository configuration, secure automated installation, JVM heap optimization, and cluster operational verification.
Elasticsearch is a distributed, RESTful search and analytics engine capable of indexing and querying billions of documents with millisecond latency. This tutorial demonstrates how to install Elasticsearch on Ubuntu 24.04 LTS using the official Elastic 8.x repository, configure security certificates, tune JVM memory allocation, and verify cluster health.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A 64-bit Ubuntu 24.04 LTS system with at least 4 GB of RAM (8 GB or more recommended for production indexing).
- A user account with sudo administrative privileges.
- An active Internet connection to download Elastic repository packages.
- The
curl,gpg, andapt-transport-httpspackages installed.
Step 1: Installing Required Dependencies and Transport Packages
Before configuring third-party software repositories, ensure your Ubuntu server has the necessary networking and encryption utilities installed.
Open your terminal and install curl, gpg, and apt-transport-https.
# Refresh package lists and install utilities
sudo apt update
sudo apt install -y curl gpg apt-transport-https ca-certificates
Step 2: Importing the Official Elastic GPG Public Key
Elastic digitally signs all Debian packages with an official GPG key. In compliance with Ubuntu 24.04 repository security policies, download and dearmor the public signing key into /etc/apt/keyrings/elasticsearch-keyring.gpg.
Execute the following commands to import and secure the key:
# Create the keyrings directory with proper permissions
sudo install -m 0755 -d /etc/apt/keyrings
# Download and dearmor the Elastic GPG signing key
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor | sudo tee /etc/apt/keyrings/elasticsearch-keyring.gpg > /dev/null
# Set read permissions
sudo chmod 0644 /etc/apt/keyrings/elasticsearch-keyring.gpg
Step 3: Configuring the Official Elastic 8.x APT Repository
With the signing key anchored in your keyrings directory, add the official Elastic 8.x repository source definition to /etc/apt/sources.list.d/elastic-8.x.list.
Ensure the source definition explicitly specifies the signed-by attribute.
# Add the Elastic 8.x APT repository
echo "deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
Step 4: Installing Elasticsearch via APT
Elasticsearch 8.x enables security by default. The installation terminal output prints a one-time generated password for the elastic superuser along with HTTP CA fingerprints and Kibana enrollment tokens. Copy and save these credentials immediately!
Update your local package lists so APT fetches package metadata from the new Elastic repository, then install the elasticsearch package.
Pay close attention to the terminal output during installation.
# Refresh package lists
sudo apt update
# Install Elasticsearch
sudo apt install -y elasticsearch
Step 5: Configuring JVM Heap Size for Production Stability
Elasticsearch allocates memory for indexing buffers and query caches via JVM heap memory. By default, Elasticsearch automatically sizes the heap, but production deployments require explicit sizing based on host RAM.
The golden rule of Elasticsearch memory allocation is to assign 50% of total available system RAM to the JVM heap, leaving the remaining 50% for the Linux kernel filesystem cache (Lucene). The heap should never exceed 31 GB.
Create a custom heap options file in /etc/elasticsearch/jvm.options.d/heap.options:
# For a server with 8 GB total RAM, allocate 4 GB to the JVM heap
echo "-Xms4g" | sudo tee /etc/elasticsearch/jvm.options.d/heap.options
echo "-Xmx4g" | sudo tee -a /etc/elasticsearch/jvm.options.d/heap.options
Step 6: Starting and Enabling the Elasticsearch Service
Reload the systemd daemon to pick up the newly installed service unit, then start and enable Elasticsearch to launch upon boot.
Elasticsearch requires 15 to 30 seconds to initialize keystores and generate cryptographic TLS certificates on first start.
# Reload systemd and start Elasticsearch
sudo systemctl daemon-reload
sudo systemctl enable --now elasticsearch
# Verify operational status
sudo systemctl status elasticsearch
Step 7: Testing Cluster Connectivity and Health with cURL
Because Elasticsearch 8.x enforces HTTPS and TLS authentication by default, querying the local REST endpoint requires specifying the generated CA certificate and providing the elastic superuser credentials.
Query the root cluster endpoint on port 9200 using curl.
# Query the local cluster using the generated CA certificate
sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:YOUR_GENERATED_PASSWORD https://localhost:9200/
# Expected JSON response:
# {
# "name" : "ubuntu-server",
# "cluster_name" : "elasticsearch",
# "cluster_uuid" : "8FjK4sL1Qy2aBcDeFgHiJk",
# "version" : {
# "number" : "8.13.4",
# "build_flavor" : "default",
# "build_type" : "deb",
# "lucene_version" : "9.10.0"
# },
# "tagline" : "You Know, for Search"
# }
Resetting the Elastic Password if Misplaced
If you missed the generated password during the APT installation output, you can reset it instantly using the bundled CLI utility:
# Reset the elastic user password interactively
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
max virtual memory areas vm.max_map_count [65530] is too low.
Cause: Elasticsearch requires a higher memory map area limit than standard Linux desktop defaults.
Resolution: Set vm.max_map_count=262144 in /etc/sysctl.conf and apply with sudo sysctl -p.
echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
curl: (60) SSL certificate problem: self-signed certificate in certificate chain.
Cause: Querying https://localhost:9200 without specifying the auto-generated HTTP CA certificate.
Resolution: Pass --cacert /etc/elasticsearch/certs/http_ca.crt or use -k for insecure testing.
sudo curl -k -u elastic https://localhost:9200
Elasticsearch service exits with code 143 or OOM killer kills process.
Cause: The JVM heap was configured larger than the available physical RAM on the server.
Resolution: Lower the JVM heap allocation in /etc/elasticsearch/jvm.options.d/heap.options to fit within physical RAM.
sudo nano /etc/elasticsearch/jvm.options.d/heap.options
Security Best Practices and Hardening
Never bind Elasticsearch to network.host: 0.0.0.0 on a public IP address without configuring strong firewall rules or VPN tunnels.
Always keep TLS security and token authentication enabled to prevent unauthorized index tampering or data exfiltration.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Add Swap Space on Ubuntu — Configure system swap to protect against catastrophic kernel OOM crashes during heavy indexing.
- How to Install Java on Ubuntu 24.04 — Learn how Java runtimes and JVM memory options operate on Ubuntu systems.
- How to Set Up a Firewall with UFW on Ubuntu — Protect Elasticsearch port 9200 from unauthorized public network exposure.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
/usr/share/elasticsearch/jdk/. You do not need to install an external Java package unless you choose to override the bundled runtime./etc/elasticsearch/elasticsearch.yml, set network.host: ["_local_", "192.168.1.50"] replacing with your private IP. Ensure discovery.seed_hosts is configured and UFW allows port 9200 from your trusted subnets.sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:<password> https://localhost:9200/_cluster/health?pretty. The status will report 'green', 'yellow', or 'red'.sudo apt purge elasticsearch and remove configuration/data directories: sudo rm -rf /etc/elasticsearch /var/lib/elasticsearch /var/log/elasticsearch.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!