3

I have deployed elasticsearch(7.3 version) service on my EC2 instance.

  • After installing when I did curl localhost:9200it gave me correct response but when I accessed the same service by hitting request:http://{{public-ip-address-ec2-instance}}:9200

It is giving error as :

This site can’t be reached : {{public-ip-address-ec2-instance}} connection refused.

  • I have configured security group of EC2 instance by allowing inbound traffic on custom TCP which is set to default elastic search port 9200 and is open to 0.0.0.0/0.

Currently I haven't modified elasticsearch.yml and it has default values only.

So how can I access elasticsearch through public IP of EC2 instance? Do I need to make any changes in elasticsearch configuration file?

  • Is your instance exposed to the Internet? You need an IGW attachment for your subnet to be able publicly access the machine. – Munavir Chavody Aug 17 '19 at 07:35
  • Yes it is exposed to Internet. –  Aug 17 '19 at 07:36
  • This seems like a connectivity issue. Can you test the connectivity using `telnet` or `nc` to the specific IP on 9200 and verify the results? – Munavir Chavody Aug 17 '19 at 07:38
  • I am able to ping this EC2 instance from my localhost by allowing through ICMP port. Additionally, I have other services as well (like ember) that is running on this EC2 instance and these other services I am able to access through public IP address of EC2 instance. –  Aug 17 '19 at 07:41
  • 4
    You need to set `network.host` in your `elasticsearch.yml` config file. [This might help](https://stackoverflow.com/questions/36397922/elasticsearch-instance-not-reachable-from-outside-the-server-azure-windows-201/36398332#36398332) – Val Aug 17 '19 at 07:42
  • @Val After changing elasticsearch.yml to above mentioned network host and restarting service I got error as: ` bound or publishing to a non-loopback address, enforcing bootstrap checks. ERROR: [2] bootstrap checks failed` –  Aug 17 '19 at 07:45
  • @Val I resolved this error by adding discovery.type: single-node and its working fine now. Thanks for your help. –  Aug 17 '19 at 07:55

1 Answers1

6

So the solution was simply to modify the following settings in elasticsearch.yml:

network.host: 0.0.0.0
discovery.type: single-node

Note: The second setting is only necessary if you have a single node.

Val
  • 207,596
  • 13
  • 358
  • 360
  • Yes! Thanks for this answer :) **BE CAREFUL**: setting `cluster.initial_master_nodes: ubuntu.local` instead of `discovery.type: single-node` can make ES (from your EC2 instance) unreachable (no idea why tho) – Emixam23 Mar 15 '22 at 22:39