Unable to access EC2 ElasticSearch7.5.2 Server using EC2 Public IP on local machine

I am using Elasticsearch7.5.2 on EC2 instance and I have modified config/elasticsearch.yml as:

network.host: 0.0.0.0
node.master: true
node.data: true
transport.host: localhost
transport.tcp.port: 9300

I can access it inside EC2 by using localhost and EC2 private IP. See attached images:1 2
But when I use public IP of EC2 to access it from my local machine. It doesn't give any response. See attached image:

Anyone who can help?

Hi @shaheryar.malik,

can you check that the Elasticsearch java process did bind its port 9200 to the specified ip?

Also, this could be a firewall problem between your local machine and the setup. Can you do

curl 13.232.42.209:9200

from the local machine and/or from a machine in same VPC or different VPC?

Hi @shaheryar.malik.
please check as below , it may be helpful to you!
We can’t access this elastic search from remote machine as below image :

For localhost or private IP-
image
For VM Public IP :-1:
image

we need to make as IP based elastic search for access through the network


Edit hosts file as below :
$nano /etc/hosts

Just map IGIVM with VM Public IP address as below :

Save this file .
image
Stop elastic search and restart It as below image:-
Command :-

$systemctl stop elasticsearch.searvice

$ systemctl start elasticsearch.searvice

$ systemctl status elasticsearch.searvice

NOW WE CAN SEE ELASTIC SEARCH IS UP AND RUNNING.
image
NOW we can access this elastic search from remote machine
image

Thanks
HadoopHelp

2 Likes

I am quite new. Please let me know specific file that I need to verify. On EC2 security group, for testing, I have allowed "All Traffic".

How can I access /etc/hosts since on EC2 Windows Instance, I have only these folders: 4

Hi @shaheryar.malik.

This is only related with elastic search files .

i think your elastic has been installed on windows ?

as i shared that is related with Azure VM.but in your case also config will be same.

Thanks
HadoopHelp

Ho @shaheryar.malik.

this host file also there with windows machine.

just check - in my case win10

like below- "C:\ **Windows** \System32\drivers\etc\ **hosts** ".

Thanks
HadoopHelp

Hi, I have applied everything but unable to access ES from EC2 public IP.
Here are screenshots so you can check:
/config/elasticsearch.yml
ES
/etc/hosts


When I run ES, these are the logs:

Here is major problem, I am trying to access from EC2 public IP which is mapped with IGIVM in hosts file. I am still unable to access :frowning:

Let me know if I am missing something!

Hi @shaheryar.malik.

so now i am sure. your elastic search has been installed in windows machine as i am looking and you want to access the same elastic search over a network as i shared ?

pls confirm me about above?

this is your machine IP-172.31.33.208:9200?

i think , this ip172.31.33.208:9200 you can access?

Thanks
HadoopHelp

172.31.33.208 is private IP of EC2 while 15.206.171.100 is public IP.

where you installed elatic search ?
on top of EC2 or local windows ?

Yes, ES is in EC2. And I want to access on local windows.

Hi @shaheryar.malik.

> if your elastic is running on EC2 then you need to check same configuration there only(EC2).

why you are using windows elastic config files here with windows machine.
in simple , you want to access / query that EC2 elastic from windows machine right?

Note-you need to check all config file with EC2 only .

within EC2 - there two IP is there one is Private and another is Public ,
you need to bind public IP here as i did in my case.

Thanks
HadoopHelp

This is it. I've finished the same on my own.

Hi @Sam_Xiao.

please help him @shaheryar.malik .

if you had done.

Thanks
HadoopHelp

Well.. you're comment is really clear enough. Good share by the way. Thanks.

I bind ec2 public IP in hosts file but that did not work. Please explain what is meant by this "if your elastic is running on EC2 then you need to check same configuration there only(EC2)."
Just to clear, I have binaries of elasticsearch in EC2 Windows Instance and that has private and public ips. Within EC2 it is accessible via private ip but in my local machine, it is not accessible via public ip which I bind in EC2 hosts file.

I am working in windows ec2 instance. If you can share all files that you modified and public/private ips that you bind in ec2, that might help.

We adjust the config:

you should use private IP or 0.0.0.0

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.