Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200) (Faraday::ConnectionFailed) Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200) (Faraday::ConnectionFailed) elasticsearch elasticsearch

Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200) (Faraday::ConnectionFailed)


In the settings you posted, your HTTP and TCP ports have the same port number assigned

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

I would suggest changing the transport.tcp.port and trying again.

Try using the defaults unless you already have port 9300 in use:

network.host: 127.0.0.1transport.tcp.port: 9300http.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.

If your service script has a status function, this may tell you if your Elasticsearch instance has started up properly or not. Failing this, you can use ps aux to determine if it is running.

$ 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).


Do you have Docker? The only solution for me was unninstall Docker completely.Otherwhise, i think the problem is something about the port that docker use.

If you don't use alot like me, just remove it and you're good to go.