0

Elasticsearch: Failed to connect to localhost port 9200: Connection refused

Elasticsearch: Failed to connect to localhost port 9200: Connection refused

I installed Elasticsearch, but each time I tried to check the status I got the error

Error:

curl -X GET 'http://127.0.0.1:9200'
curl: (7) Failed to connect to localhost port 9200 after 0 ms: Connection refused

To fix this, open /etc/elasticsearch/elasticsearch.yml and add check the following configuration Line.
Default values:

cluster.name: my-application
network.host: 192.168.0.1
http.port: 9200
discovery.seed_hosts: ["host1", "host2"]
cluster.initial_master_nodes: ["node-1", "node-2"]
xpack.security.enabled: true
cluster.initial_master_nodes: ["systemhostname"]

Modified values:

cluster.name: elasticsearch
network.host: 127.0.0.1
http.port: 9200
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["127.0.0.1"]
xpack.security.enabled: false
#cluster.initial_master_nodes: ["systemhostname"]

Then restart the Elasticsearch service

Elastic Search Add a comment
noah
asked Jun 12 2024
edited Jun 12 2024