简体   繁体   English

无法打开到localhost的TCP连接:9200(连接被拒绝 - 连接(2)为“localhost”端口9200)(法拉第::连接失败)

[英]Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for “localhost” port 9200) (Faraday::ConnectionFailed)

I am getting the error: Puma caught this error: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200) (Faraday::ConnectionFailed) in my rails application in ubuntu 14.04. 我收到错误:Puma发现了这个错误:无法打开到localhost的TCP连接:9200(连接被拒绝 - 连接(2)for“localhost”端口9200)(Faraday :: ConnectionFailed)在我的rails应用程序中的ubuntu 14.04。

below is the output of my elastic search in terminal: 下面是我在终端弹性搜索的输出:

prashanth@prashanth-OptiPlex-390:~$ sudo service elasticsearch restart
 * Starting Elasticsearch Server                                                                                                               prashanth@prashanth-OptiPlex-390:~$ sudo service elasticsearch start
 * Starting Elasticsearch Server                                                                                                                * Already running.                                                                                                                     [ OK ] 
prashanth@prashanth-OptiPlex-390:~$ curl -X GET 'http://localhost:9200'
curl: (7) Failed to connect to localhost port 9200: Connection refused
prashanth@prashanth-OptiPlex-390:~$ 

here are the my elastic search settings in /etc/elasticsearch/elasticsearch.yml file 这是我在/etc/elasticsearch/elasticsearch.yml文件中的弹性搜索设置

network.host: 127.0.0.1
transport.tcp.port: 9200
http.port: 9200

error description: 错误描述:

Puma caught this error: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200) (Faraday::ConnectionFailed)
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:878:in `connect'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:852:in `start'
/home/prashanth/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1398:in `request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/adapter/net_http.rb:83:in `perform_request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/adapter/net_http.rb:41:in `block in call'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/adapter/net_http.rb:88:in `with_net_http_connection'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/adapter/net_http.rb:33:in `call'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/rack_builder.rb:139:in `build_response'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/faraday-0.10.1/lib/faraday/connection.rb:377:in `run_request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/elasticsearch-transport-5.0.0/lib/elasticsearch/transport/transport/http/faraday.rb:23:in `block in perform_request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/elasticsearch-transport-5.0.0/lib/elasticsearch/transport/transport/base.rb:257:in `perform_request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/elasticsearch-transport-5.0.0/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
/home/prashanth/.rvm/gems/ruby-2.3.1/gems/elasticsearch-transport-5.0.0/lib/elasticsearch/transport/client.rb:128:in `perform_request'

In the settings you posted, your HTTP and TCP ports have the same port number assigned 在您发布的设置中,您的HTTP和TCP端口具有相同的端口号

network.host: 127.0.0.1
transport.tcp.port: 9200
http.port: 9200

I would suggest changing the transport.tcp.port and trying again. 我建议更改transport.tcp.port并再次尝试。

Try using the defaults unless you already have port 9300 in use: 尝试使用默认值,除非您已使用端口9300:

network.host: 127.0.0.1
transport.tcp.port: 9300
http.port: 9200

If you are still facing issues, you may need to open up the ports on your firewall program. 如果您仍然遇到问题,可能需要打开防火墙程序上的端口。 On Ubuntu, this is likely UFW. 在Ubuntu上,这可能是UFW。

If your service script has a status function, this may tell you if your Elasticsearch instance has started up properly or not. 如果您的服务脚本具有状态功能,则可能会告诉您Elasticsearch实例是否已正确启动。 Failing this, you can use ps aux to determine if it is running. 如果不这样做,您可以使用ps aux来确定它是否正在运行。

$ sudo service elasticsearch status

Or 要么

$ ps aux | grep elasticsearch

As pointed out in similar questions, cURL can give a refused connection error when Elasticsearch isn't running (source: Faraday::ConnectionFailed, Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails ). 正如类似的问题所指出的,当Elasticsearch没有运行时,cURL会给出拒绝的连接错误(来源: Faraday :: ConnectionFailed,连接被拒绝 - 连接(2)为“localhost”端口9200错误Ruby on Rails )。

Do you have Docker? 你有Docker吗? The only solution for me was unninstall Docker completely. 对我来说唯一的解决方案是完全卸载Docker。 Otherwhise, i think the problem is something about the port that docker use. 另外,我认为这个问题与Docker使用的端口有关。

If you don't use alot like me, just remove it and you're good to go. 如果你不像我一样使用很多,只需将它移除即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 法拉第:: ConnectionFailed,连接被拒绝 - 连接(2)为“localhost”端口9200 - Faraday::ConnectionFailed, Connection refused - connect(2) for “localhost” port 9200 法拉第:: ConnectionFailed连接被拒绝 - 连接(2)为“localhost”端口9200 - Faraday::ConnectionFailed Connection refused - connect(2) for “localhost” port 9200 法拉第:: ConnectionFailed,连接被拒绝 - 连接(2)为“localhost”端口9200错误Ruby on Rails - Faraday::ConnectionFailed, Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails 无法打开 TCP 到 localhost:9200 的连接(无法分配请求的地址 - “localhost”端口 9200 的连接(2)) - Failed to open TCP connection to localhost:9200 (Cannot assign requested address - connect(2) for “localhost” port 9200) 连接被拒绝 - 使用DigitalOcean连接(2)“localhost”端口9200 - Connection refused - connect(2) for “localhost” port 9200 with DigitalOcean 无法打开到 localhost:9200 的 TCP 连接 - Docker 上的 Rails - Failed to open TCP connection to localhost:9200 - Rails on Docker # <Faraday::ConnectionFailed> 连接被拒绝 - 连接(2) - #<Faraday::ConnectionFailed> Connection refused - connect(2) Rspec无法运行:在connection_for中进行救援:连接被拒绝:localhost:7475(法拉第:: ConnectionFailed) - Rspec can't run: rescue in connection_for': connection refused: localhost:7475 (Faraday::ConnectionFailed) KOALA + FACEBOOK GRAPH给出了FARADAY错误(ConnectionFailed-拒绝连接-connect(2)) - KOALA + FACEBOOK GRAPH gives FARADAY error (ConnectionFailed - Connection Refused - connect(2)) curl: (7) 无法连接到本地主机端口 3000:连接被拒绝 - curl: (7) Failed to connect to localhost port 3000: Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM