This guide walks you through installing and configuring Elasticsearch 8.x on Ubuntu/Debian systems using the official Elastic APT repository.
All steps are based on the official Elastic documentation.
Update your package index and install the required dependencies:
sudo apt update && sudo apt upgrade -y
sudo apt install apt-transport-https ca-certificates curl -ycurl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic-archive-keyring.gpgecho "deb [signed-by=/usr/share/keyrings/elastic-archive-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt updateThis is the official method recommended by Elastic for Debian-based systems.
Install Elasticsearch using APT:
sudo apt install elasticsearch -yAfter installation, enable and start the Elasticsearch service:
sudo systemctl daemon-reload
sudo systemctl enable --now elasticsearch.service
sudo systemctl status elasticsearch.serviceTo verify if Elasticsearch is running, execute:
curl -k https://localhost:9200You should see a JSON response with cluster information.
Edit the main configuration file:
sudo nano /etc/elasticsearch/elasticsearch.ymlExample configuration:
cluster.name: my-cluster
node.name: node-1
network.host: 0.0.0.0 # Allow external access (use only for development)
http.port: 9200Edit the JVM options file (adjust for your system resources):
sudo nano /etc/elasticsearch/jvm.options.d/jvm.optionsExample:
-Xms2g
-Xmx2g
Note:
Usenetwork.host: 0.0.0.0only for development/testing.
In production, always bind to a specific IP and use proper security (firewall, TLS, and authentication).
Starting with Elasticsearch 8.x, X-Pack Security is enabled by default.
During the initial startup, Elasticsearch may auto-generate:
- Security certificates
- A bootstrap password for the built-in
elasticsuperuser
If you installed manually, follow the recommended password setup procedure below.
Elasticsearch provides the elasticsearch-reset-password utility for managing built-in user passwords.
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password --interactive -u elasticsudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elasticFollow the prompts to set or reset the password.
If your cluster is new and initial passwords have not been set,
you can also use (deprecated but available):sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
Use your new password to verify authentication:
curl -u elastic:YOUR_PASSWORD -k https://localhost:9200If successful, you’ll receive the cluster information in JSON format.
If elasticsearch-reset-password is not found or fails:
- Make sure the Elasticsearch service is running.
- Run the command from inside
/usr/share/elasticsearch/bin/.
Older versions used:
bin/elasticsearch-setup-passwords autobut this method is deprecated in 8.x.
- Elastic Official Docs – Install Elasticsearch with Debian Package
- Elastic Security Overview
- X-Pack Features
Jagadish Tripathy
Cybersecurity Engineer | SOC & VAPT Specialist
Documentation written for secure Elasticsearch setup (development-ready configuration).