Sandun
Sandun

Reputation: 405

ElasticSearch Connection Timed Out in EC2 Instance

I am setting up an ELK Stack (which consists of ElasticSearch, LogStash and Kibana) in a single EC2 instance. AWS EC2 instance. I am following the documentation from the elastic.co site.

TL;DR; I cannot access my ElasticSearch interface hosted in an EC2 from the Web URL. How to fix that?

Type : m4.large
vCPU : 2
Memory : 8 GB
Storage: 25 GB (EBS)

Note : I have provisioned the EC2 instance inside a VPC and with an Elastic IP.

I have installed all 3 components. ElasticSearch and LogStash are running as services while Kibana is running via the command ./bin/kibana inside kibana-7.10.1-linux-x86_64/ directory.

When I curl the ElasticSearch endpoint using

curl http://localhost:9200 

I get this JSON output. (Which means the service is running and is accessible via Port 9200).

enter image description here

However, when I try to access the same URL via my browser, I get an error saying

Connection Timed Out

enter image description here

Isn't this supposed to return the same JSON output as the one I've mentioned above?

I have attached the elasticsearch.yml file here (Hosted in gofile.io).

Here are the Inbound Rules for the EC2 instance.

enter image description here

EDIT : I tried changing the network.host: 'localhost' to network.host: 0.0.0.0 and restarted the service but this time I got an error while starting the service. I attached the screenshot of that. enter image description here

EDIT 2 : I have uploaded the updated elasticsearch.yml to Gofile.org).

Upvotes: 0

Views: 1550

Answers (1)

Val
Val

Reputation: 217254

The problem is the following line in your elasticsearch.yml configuration file:

node.name: node-1
network.host: 'localhost'

With that configuration, your ES cluster is only accessible from the same host and not from the outside. According to the official documentation, you need to either specify 0.0.0.0 or a specific publicly accessible IP address, otherwise that won't work.

Note that you also need to configure the following two lines in order for the cluster to properly form:

discovery.seed_hosts: ["node-1-ip-address"]

# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["node-1"]

Upvotes: 1

Related Questions