Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowing remote access to Elasticsearch

I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked.

Is anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server?

like image 709
Jimmy Avatar asked Aug 28 '13 22:08

Jimmy


People also ask

How do I connect to an Elasticsearch server?

There are two ways to connect to your Elasticsearch cluster: Through the RESTful API or through the Java transport client. Both ways use an endpoint URL that includes a port, such as https://ec47fc4d2c53414e1307e85726d4b9bb.us-east-1.aws.found.io:9243 .

How do you expose Elasticsearch to public?

You need to include network. host:0.0. 0.0 in your elasticsearch. yml file so that it listens on the non-loopback address and after that, if your app-server and ES are both in the same VPC, app-server will be able to connect to ES(provided if you exposed 9200 port in security group(in case of AWS).


2 Answers

In config/elasticsearch.yml, put network.host: 0.0.0.0. And also add Inbound Rule in firewall for your ElasticSearch port(9200 ByDefault). It worked in ElasticSearch version 2.3.0

like image 73
Jay Shah Avatar answered Sep 23 '22 01:09

Jay Shah


When elasticsearch is installed and run without any configuration changes by default it binds to localhost only. To access the elasticsearch REST API endpoint remotely the below changes has to be made on the server where elasticsearch has been installed.

  • Elasticsearch Configuration Change Update the network.host property in elasticsearch.yml as per the guidelines provided in the elasticsearch documentation For example to bind to all IPv4 addresses on the local machine, change as below network.host : 0.0.0.0

  • Firewall Rules Update Update the Linux firewall to allow access to port 9200. Please refer your Linux documentation for adding rules to the firewall.

For example to allow access to all the servers(public) in CentosOS use the firewall-cmd

sudo firewall-cmd --zone=public --permanent --add-port=9200/tcp
sudo firewall-cmd --reload

Note : In production environment public access is discouraged. A restricted access should be preferred.

like image 23
Harish Kumar Avatar answered Sep 23 '22 01:09

Harish Kumar