Elasticsearch is an open-source distributed search and analytics engine built on Apache Lucene. It supports RESTful operations and lets you store, search, and analyze large volumes of data in real time.
It is used across large e-commerce platforms, log analysis pipelines as part of the ELK stack (alongside Logstash and Kibana), machine learning anomaly detection, and any application that needs fast, scalable full-text search across millions of records.
This guide covers installing Elasticsearch on Ubuntu 18.04 from the official Elastic repository, verifying the service, and configuring remote access with UFW.
Prerequisite: You need sudo access.
Elasticsearch requires Java 8. Start by updating the package list and installing the HTTPS transport package:
bashsudo apt updatesudo apt install apt-transport-https
Install OpenJDK 8:
bashsudo apt install openjdk-8-jdk
Import the Elasticsearch repository GPG signing key:
bashwget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
A response of OK confirms the key was imported and packages from this repository will be trusted. Add the Elastic repository:
bashsudo sh -c 'echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
Update the package list and install Elasticsearch:
bashsudo apt updatesudo apt install elasticsearch
The service does not start automatically after installation. Enable and start it manually:
bashsudo systemctl enable elasticsearch.servicesudo systemctl start elasticsearch.service
It takes around 10 seconds to fully start. Verify it is running by sending an HTTP request to port 9200:
bashcurl -X GET "localhost:9200/"
A successful response returns a JSON object containing the cluster name, version number, and Elastic’s tagline “You Know, for Search”. If you see a connection refused error, wait a few more seconds and try again. To view service logs for debugging, run sudo journalctl -u elasticsearch.
Elasticsearch stores data in /var/lib/elasticsearch. Configuration files are in /etc/elasticsearch/elasticsearch.yml and Java startup options are in /etc/default/elasticsearch.
By default, Elasticsearch only listens on localhost. For single-node setups where your application and Elasticsearch share the same host, the default configuration is sufficient and no changes are needed.
<strong>Security warning:</strong> Elasticsearch has no built-in authentication by default. Anyone who can reach port 9200 can read and modify your data. Restrict access with firewall rules before exposing Elasticsearch to any network.
Allow SSH first so you do not lock yourself out:
bashsudo ufw allow 22
Allow access to port 9200 only from your trusted client IP:
bashsudo ufw allow from 192.168.100.20 to any port 9200
Enable UFW and verify the rules are active:
bashsudo ufw enablesudo ufw status
Update the Elasticsearch configuration to accept external connections:
bashsudo nano /etc/elasticsearch/elasticsearch.yml
Uncomment the network.host line and set the value:
network.host: 0.0.0.0
To bind to a specific network interface instead of all interfaces, replace 0.0.0.0 with the server’s private IP address.
Restart Elasticsearch to apply the changes:
bashsudo systemctl restart elasticsearch
Elasticsearch is now installed and running on your Ubuntu 18.04 server. Visit the official Elasticsearch documentation to get started with indexing documents, writing search queries, and managing clusters. Leave a comment below if you run into any issues.
Opera is one of the most popular cross-platform web browsers in the world, available on Windows,…
Gogs is a free, self-hosted Git service written in Go. It gives you a private GitHub-like…
Flask is a free, open-source micro web framework for Python. It is built on Werkzeug and…
Memcached is a free, open-source, high-performance in-memory caching system. It stores data as key-value pairs in…
TensorFlow is a free, open-source machine learning platform developed by Google. It is used by major…
Minecraft is one of the most popular games ever made — a sandbox game where players…