问题描述
我有一个运行Elasticsearch的e2 ubuntu实例,尽管它在本地运行良好,但是我无法使用curl http://ipaddress:9200/
从Windows pc连接(错误是无法连接到远程服务器").
I have an e2 ubuntu instance running elasticsearch, and although it works fine locally, I can't connect from a windows pc using curl http://ipaddress:9200/
(error is "unable to connect to the remote server").
我已经在同一ubuntu实例上设置了Apache,并且curl http://ipaddress:80/
在同一Windows机器上工作,&我可以毫不费力地对实例执行ping操作.我的亚马逊安全组允许tcp从所有IP地址访问所有端口.
I've set up Apache on the same ubuntu instance and curl http://ipaddress:80/
works from the same windows machine, & I can ping the instance with no trouble.My amazon security group allows tcp access to all ports from all IP addresses.
我认为这是一个ES配置问题,尽管我添加到elasticsearch.yml的唯一几行是:
I think it's an ES config issue, although the only lines I've added to elasticsearch.yml are:
http.cors.enabled: true
http.cors.allow-origin: "*"
运行netstat时,我发现有些奇怪的地方,端口9200和9300(ES端口)的本地地址中有一个1-这会阻止我的外部请求吗?如果是的话,如何更改此请求?
I've noticed something strange when I run netstat, there's a 1 in the Local address for ports 9200 and 9300 (ES ports) - would this block my external request, and if so how do I change this?
ubuntu@ESServer$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 448 (AWS PRIVATE IP):22 (MY IP):63572 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:9200 :::* LISTEN
tcp6 0 0 127.0.0.1:9200 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 ::1:9300 :::* LISTEN
tcp6 0 0 127.0.0.1:9300 :::* LISTEN
推荐答案
似乎您的Elasticsearch进程已绑定到本地主机.尝试像这样运行它:
It seems that your elasticsearch process is bind to localhost. Try to run it like this:
bin/elasticsearch --network.host _non_loopback_
从2.0开始,elasticsearch绑定到本地主机.因此,您将无法访问它.
Since 2.0 elasticsearch binds to localhost. For that reason you are not able to access it.
这篇关于ES不监听外部请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!