1
votes

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?

1
Is your instance exposed to the Internet? You need an IGW attachment for your subnet to be able publicly access the machine.Munavir Chavody
Yes it is exposed to Internet.user11935734
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
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.user11935734
You need to set network.host in your elasticsearch.yml config file. This might helpVal

1 Answers

3
votes

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.