elasticsearch - 无法访问localhost:9200 via curl

时间:2018-06-01 07:25:58

标签: elasticsearch

我启动elasticsearch服务器并希望通过curl访问localhost:9200

这是我的尝试:

curl -u elastic:H5VzhJP0txg4Lm9EMSZp localhost:9200

curl -u elastic:H5VzhJP0txg4Lm9EMSZp http://localhost:9200

curl -u elastic:H5VzhJP0txg4Lm9EMSZp http://127.0.0.1:9200

curl -XGET -u elastic:H5VzhJP0txg4Lm9EMSZp http://localhost:9200

curl -XGET -u elastic:H5VzhJP0txg4Lm9EMSZp -H 'Content-Type: application/json' 'http://localhost:9200'

他们都给我结果:curl: (52) Empty reply from server

但是,我可以通过浏览器访问localhost:9200

这是我的elasticsearch版本:

☁  kibana-research [master] ⚡  elasticsearch --version
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory

Version: 6.2.4, Build: ccec39f/2018-04-12T20:37:28.497551Z, JVM: 1.8.0_171

2 个答案:

答案 0 :(得分:0)

我认为原因是proxy

这是~/.zshrc文件

中的配置
 98 # proxy list
 99 alias proxy='export all_proxy=socks5://127.0.0.1:1086'
100 alias unproxy='unset all_proxy'

当我在终端中运行unproxy时,这意味着我不会使用代理服务器。

然后,它工作正常。

☁  kibana-research [master] ⚡  curl -u elastic:H5VzhJP0txg4Lm9EMSZp localhost:9200
{
  "name" : "KBgeNNv",
  "cluster_name" : "elasticsearch_ldu020",
  "cluster_uuid" : "Src22ahwTYy9jVthB8w0DQ",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

答案 1 :(得分:0)

试试这个。

curl 'username:password@localhost:9200'
curl 'username:password@localhost:9200' -H 'Content-Type: application/json'