CentOS: how to open port to remote Elasticsearch


Step 1: Edit file /etc/elasticsearch/elasticsearch.yml

vi /etc/elasticsearch/elasticsearch.yml

Uncomment line:

#network.host: 192.168.0.1

Change 192.168.0.1 to 0.0.0.0 (or your server ipaddress)

Step 2:

service elasticsearch restart

Step 3: open port with iptables

iptables -A INPUT -p tcp -m tcp --dport 9200 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 9300 -j ACCEPT
service iptables save

Done! check

[root@tutorialspots ~]# curl http://111.111.111.111:9200
{
  "name" : "xGTksWR",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "wpdPMEalTBWbxCE-ddMMMQ",
  "version" : {
    "number" : "6.2.3",
    "build_hash" : "c59ff00",
    "build_date" : "2018-03-13T10:06:29.741383Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Leave a Reply