September 05, 2026 · by Alex M.
Elasticsearch is one of the most widely used open-source search and analytics engines in the world. Whether you're running a high-traffic website, an e-commerce platform, a log analysis system, or any application that requires fast, flexible full-text search, Elasticsearch is the go-to solution. In this guide, you'll learn how to install, configure, and secure Elasticsearch on a NVMe VPS or SSD VPS running Ubuntu 22.04.
Elasticsearch is built on top of the Apache Lucene library and provides:
For reliable production use, Elasticsearch requires at least 2 GB of RAM and 2 vCPUs. We recommend a NVMe VPS for maximum performance during heavy indexing operations.
Before you begin, make sure you have:
sudo privileges9200 (HTTP) and 9300 (transport) availableAlways start with a full package update:
sudo apt update && sudo apt upgrade -y
Elasticsearch is not available in the default Ubuntu repositories. Add the official Elastic source:
# Import GPG key
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
# Add the 8.x repository
echo "deb [signed-by=/usr/share/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
# Update package list
sudo apt update
sudo apt install elasticsearch -y
After installation, the terminal will display a temporary password for the elastic superuser — save it immediately!
The generated password for the elastic built-in superuser is:
XXXXXXXXXXXXXXXXXXX
The main configuration file is located at /etc/elasticsearch/elasticsearch.yml. Open it with a text editor:
sudo nano /etc/elasticsearch/elasticsearch.yml
Modify or verify these essential settings:
# Cluster name (unique on the network)
cluster.name: my-cluster
# Node name
node.name: node-1
# Data storage directory
path.data: /var/lib/elasticsearch
# Log directory
path.logs: /var/log/elasticsearch
# Listening address (127.0.0.1 for local use; 0.0.0.0 for network)
network.host: 127.0.0.1
# HTTP port
http.port: 9200
# Single-node discovery (for standalone VPS)
discovery.type: single-node
# Enable X-Pack security
xpack.security.enabled: true
Tip: If Elasticsearch is only used by applications on the same server, keep
network.host: 127.0.0.1for maximum security.
Elasticsearch relies heavily on Java heap memory. Adjust the limits based on available RAM:
sudo nano /etc/elasticsearch/jvm.options.d/jvm-custom.options
Add (for a 4 GB RAM VPS, allocate 2 GB to Elasticsearch):
-Xms2g
-Xmx2g
Golden rule: never allocate more than 50% of total RAM and never exceed 32 GB.
Elasticsearch requires specific Linux kernel adjustments:
# Increase file descriptor limits
sudo sh -c 'echo "elasticsearch soft nofile 65536" >> /etc/security/limits.conf'
sudo sh -c 'echo "elasticsearch hard nofile 65536" >> /etc/security/limits.conf'
# Set vm.max_map_count (required by Elasticsearch)
sudo sysctl -w vm.max_map_count=262144
# Make the setting persistent
echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
Check the service status:
sudo systemctl status elasticsearch
You should see Active: active (running).
Verify that Elasticsearch is responding correctly:
curl -k -u elastic:YOUR_PASSWORD https://localhost:9200
A successful response looks like this:
{
"name" : "node-1",
"cluster_name" : "my-cluster",
"version" : {
"number" : "8.x.x",
"lucene_version" : "9.x.x"
},
"tagline" : "You Know, for Search"
}
If you've lost the initial password, reset it with:
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
To create a new user with limited permissions:
sudo /usr/share/elasticsearch/bin/elasticsearch-users useradd myuser -p mypassword -r viewer
If you haven't already secured your Linux VPS with a firewall, block external access to port 9200:
# Block external access
sudo ufw deny 9200
sudo ufw deny 9300
sudo ufw allow ssh
sudo ufw enable
If you need access from another server (e.g., a separate application server), allow only that specific IP:
sudo ufw allow from 1.2.3.4 to any port 9200
For advanced security hardening, consider CLIQHOST's server management services, where our engineers handle configuration, monitoring, and updates.
Once running, you can interact with Elasticsearch via HTTP requests:
curl -k -u elastic:PASSWORD -X PUT "https://localhost:9200/products?pretty"
curl -k -u elastic:PASSWORD -X POST "https://localhost:9200/products/_doc/1?pretty" \
-H 'Content-Type: application/json' \
-d '{
"name": "Asus Laptop",
"price": 3500,
"category": "electronics"
}'
curl -k -u elastic:PASSWORD -X GET "https://localhost:9200/products/_search?q=Laptop&pretty"
curl -k -u elastic:PASSWORD -X GET "https://localhost:9200/products/_search?pretty" \
-H 'Content-Type: application/json' \
-d '{
"query": {
"range": {
"price": { "gte": 1000, "lte": 5000 }
}
}
}'
For a stable production deployment on a dedicated server or VPS, follow these best practices:
# Add to elasticsearch.yml
index.search.slowlog.threshold.query.warn: 10s
index.search.slowlog.threshold.fetch.warn: 1s
Logs are stored in /var/log/elasticsearch/. Monitor errors in real time:
sudo tail -f /var/log/elasticsearch/my-cluster.log
For more Linux server administration tips, visit the CLIQHOST blog.
Elasticsearch is a powerful tool, but it requires careful resource planning and security configuration. By following the steps in this guide, you'll have a fully functional, secured, and optimized Elasticsearch installation on your Linux VPS. The key to success is proper memory allocation, locked-down network access, and continuous monitoring.
If you need high-performance, reliable infrastructure for Elasticsearch, explore CLIQHOST's NVMe VPS plans — fast NVMe storage, dedicated resources, and expert support. For larger projects, managed dedicated servers deliver the raw compute power and hands-on assistance you need. Contact us to find the perfect fit for your workload.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."