How do I enable remote access/request in Elasticsearch 2.0?

Starting from v2.0 Elasticsearch is listening only on localhost by default, but I'd like to make request outside localhost.

For example, a request like this is allowed:

http://localhost:9200/

But this is not:

http://server_name:9200/ (from outside of the server, eg: a local computer in the same LAN).

Thanks for your help.


Solution 1:

In config/elasticsearch.yml put

network.host: 0.0.0.0

Solution 2:

By default http transport and internal elasticsearch transport only listens to localhost. If you want to access Elasticsearch from the host other than localhost then try adding following configurations in config/elasticsearch.yml.

transport.host: localhost 
transport.tcp.port: 9300 
http.port: 9200
network.host: 0.0.0.0

Here, network.host as 0.0.0.0 allow access from any host within the network.

Solution 3:

Rename the elasticsearch.yml file to elasticsearch.json inside config folder and add:

{
    "network" : {
        "host" : "10.0.0.4"
    }
}

Another option is to provide the settings externally either using the ES_JAVA_OPTS or as parameters to the elasticsearch command, for example:

$ elasticsearch -Des.network.host=10.0.0.4

Another option is to set es.default. prefix instead of es. prefix, which means the default setting will be used only if not explicitly set in the configuration file.

Another option is to use the ${...} notation within the configuration file which will resolve to an environment setting, for example:

{
    "network" : {
        "host" : "${ES_NET_HOST}"
    }
}

The location of the configuration file can be set externally using a system property:

$ elasticsearch -Des.config=/path/to/config/file

For more info, check out https://www.elastic.co/guide/en/elasticsearch/reference/1.4/setup-configuration.html

Solution 4:

In Elastic Search 7.0 update /etc/elasticsearch/elasticsearch.yml

network.host: 0.0.0.0
network.bind_host: 0.0.0.0
network.publish_host: 0.0.0.0

Additionally:

discovery.seed_hosts: ["0.0.0.0", "[::0]"]

** Don't forget to restart after changing the config. If still Elastic search not restarted check log journalctl -xe