Unable to connect to Elasticsearch from another machine


#1

I am trying to connect to Elasticsearch from another machine in C# code. I specified the Elasticsearch host machine's fully qualified domain name in the uri and tried to connect with something like the following:

Uri elasticsearchUri = new Uri("http://foo.bar.local:9200");
var settings = new ConnectionSettings(elasticsearchUri).DefaultIndex("MyIndex");
var client = new ElasticClient(settings);
var indexResponse = elasticClient.Index(data);

I got the following when executing the last line:

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it <IP address of ES host machine>:9200

In addition, the ES is hosted on a Windows Server 2012R2 virtual server. I have turned off all its firewalls. Should I unblock the connection of certain app or feature for the remote ES connection to work?

Please advise what I need to do with this. We just installed ElasticSearch and everything should be the latest.


(David Pilato) #2

You may be did not change network.host in your node settings...


#3

Thanks David! How can I change the node settings? Some details or a pointer to any documentation would be appreciated very much.


(Mark Walkom) #4

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-network.html is what you are after.


#5

Thanks David! I will peruse it.


#6

HI David,

Now to elasticsearch.yml, I added this line:

network.host:["<IP address of the ES host machine>", "<Fully qualified domain name of the ES host machine>", "_local_"]

However, I got a slightly different error:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <IP address of the ES host machine>:9200

I am able to connect and index into ES locally with http://localhost:9200 as the uri though. Is my syntax of the array for network.host wrong or something? Do I need to restart the host machine for the new network.host value to take effect?

In addition, the ES is hosted on a Windows Server 2012R2 virtual server. I have turned off all its firewalls. Should I unblock a specific app or feature to be able to connect to the ES remotely?


(Mark Walkom) #7

Just us `0.0.0.0``, then it will bind to all the interfaces (unless you have a public IP you don't want to bind to).


(system) #8

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.