Can't Connect to Elasticsearch (through Curl)
1) Check what's the status of your port 9200, with lsof
command in linux.
In my case following is the result when elasticsearch
is started.
prayag@prayag:~$ sudo lsof -i TCP | grep 9200 chrome 2639 praayg 84u IPv4 116310 0t0 TCP prayag.local:58989->10.0.4.70:9200 (ESTABLISHED)chrome 2639 prayag 99u IPv4 116313 0t0 TCP prayag.local:58990->10.0.4.70:9200 (ESTABLISHED)java 7634 prayag 141u IPv6 130960 0t0 TCP *:9200 (LISTEN)
elasticsearch
is not a service to me, otherwise to find the port es is running; on I could have checked,
$ sudo lsof -iTCP -sTCP:LISTEN | grep elasticsearch
2) check the elasticsearch endpoint
$ curl -IGET http://localhost:9200HTTP/1.1 200 OKcontent-type: application/json; charset=UTF-8content-length: 327
-IGET
is equivalent to--head
that returns http response headers only.response
200
means elasticsearch endpoint is responding properly.
curl -GET http://127.0.0.1:9200
is the wrong command.
Try curl -XGET http://127.0.0.1:9200
. It should return the short info about your running local node and status 200. If that doesn't work then something else must be wrong.