简体   繁体   中英

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

I am using DigitalOcean for my Ruby on Rails app with Elasticsearch. So I am getting

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

I am wondering if it is because I am not using localhost on DigitalOcean. I am guessing if I have to change it in my app to start listening to the ip address I am using for DigitalOcean, but am not sure where I should look at.

Can you check the following on digitalocean:

sudo vi /etc/elasticsearch/elasticsearch.yml

Look for:

network.bind_host: localhost

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

also, are you sure elasticsearch is running? The following command should give you a hash as result:

curl localhost:9200

If not: try to start it and try again:

sudo service elasticsearch start

Also, you'll probably want to boot elasticsearch automatically like described here https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM