Enable Remote Access in ElasticSearch on CentOS 7

Posted Under: CentOS, Configuration, Elasticsearch, Linux, Tutorials on Jun 11, 2017
Enable Remote Access in ElasticSearch on CentOS 7
Elasticsearch is one of the leading open-source distributed search and analytic engines. This text focuses on installing and configuring elasticsearch on a CentOS 7 with the ability to access it remotely.

First we need to download JAVA Development Kit (JDK) provided by the Oracle. Although open-JDK can work too but it is recommended to use Oracle JDK 8. Download the RPM from Oracle's site. Next download the latest RPM for ElasticSearch official website here. Current version while writing this is 5.4.1.

Next install both RPMs first JDK
rpm -ivh jdk-8u131-linux-x64.rpm
then elasticsearch
rpm -ivh elasticsearch-5.4.1.rpm
If you start the elasticsearch service now and try to access remotely you will get Connection Refused error. To enable access elasticsearch remotely open elasticsearch.yml file in vi editor.
vi /etc/elasticsearch/elasticsearch.yml
In the middle you find network section un-comment and change network.host value as show below.
# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
# Set a custom port for HTTP:
#http.port: 9200
# For more information, consult the network module documentation.
# --------------------------------- Discovery ----------------------------------
Make sure your interface card is up and have a valid IP address. You can check it using the following command.
nmcli d
Next add the following changes in your firewall setting to make it accessible remotely.
firewall-cmd --zone=public --add-port=9200/tcp --permanent 
firewall-cmd --reload
9200 is the default port for elasticsearch, Now it time to start the elasticsearch service.
sudo systemctl start elasticsearch.service
Now access the service remotely using URL http://IP_ADDRESS_SERVER:PORT you will get similar response as below.
  "name" : "7BN-_vO",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "eUOqMcipQDyv9RE9Rtt9Hg",
  "version" : {
    "number" : "5.4.1",
    "build_hash" : "2cfe0df",
    "build_date" : "2017-05-29T16:05:51.443Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.1"
  "tagline" : "You Know, for Search"