连接被拒绝 - "localhost" 端口 9200 与 DigitalOcean 的连接(2)

Connection refused - connect(2) for "localhost" port 9200 with DigitalOcean

我在 Rails 应用程序上为我的 Ruby 使用 Elasticsearch 的 DigitalOcean。所以我得到

Faraday::ConnectionFailed in PetsController#create
Connection refused - connect(2) for "localhost" port 9200

我想知道是不是因为我没有在 DigitalOcean 上使用 localhost。我猜我是否必须在我的应用程序中更改它以开始收听我用于 DigitalOcean 的 IP 地址,但我不确定我应该在哪里查看。

你能在 digitalocean 上查看以下内容吗:

sudo vi /etc/elasticsearch/elasticsearch.yml

寻找:

network.bind_host: localhost

来源:https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-on-an-ubuntu-vps

还有,你确定elasticsearch是运行吗?下面的命令应该给你一个散列作为结果:

curl localhost:9200

如果没有:尝试启动并重试:

sudo service elasticsearch start

此外,您可能希望按照此处所述自动启动 elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html