Elasticsearch: listen all network interfaces on Centos 7

By default elasticsearch listens to localhost.

# netstat -na|grep LISTEN |grep 9200
tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN
tcp6       0      0 ::1:9200                :::*                    LISTEN       

If you want to access over the network you need to edit network.host parameter /etc/elasticsearch/elasticsearch.yml  file

———————————- Network ———————————–
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
# http.port: 9200
#         

Comment out network.host and type your IP address or type 0.0.0.0 to listen all interfaces

 network.host: 0.0.0.0

and restart elasticsearch

# systemctl restart elasticsearch 

 

# netstat -na|grep LISTEN |grep 9200
tcp6       0      0 :::9200                 :::*                    LISTEN

# curl http://192.168.1.112:9200
{
  “name” : “Phantom Eagle”,
  “cluster_name” : “elasticsearch”,
  “cluster_uuid” : “k9tOhsoyTrOnvR-QpUpHxA”,
  “version” : {
    “number” : “2.4.1”,
    “build_hash” : “c67dc32e24162035d18d6fe1e952c4cbcbe79d16”,
    “build_timestamp” : “2016-09-27T18:57:55Z”,
    “build_snapshot” : false,
    “lucene_version” : “5.5.2”
  },
  “tagline” : “You Know, for Search”
}          

In this case, your elasticsearch will be accessible from network without any restriction. You should enable IP based filtering/firewall or user authentication.

ismail yenigul

 

Advertisements
Elasticsearch: listen all network interfaces on Centos 7