# Unable to connect to Elasticsearch from another machine

**URL:** <https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392>\
**Category:** Elasticsearch\
**Created:** [September 21, 2017, 8:37pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392 "2017-09-21T20:37:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jxz](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jxz](https://discuss.elastic.co/u/jxz)\
**Post date:** [September 21, 2017, 8:37pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/1 "2017-09-21T20:37:07Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 21, 2017, 9:00pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/2 "2017-09-21T21:00:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jxz](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jxz](https://discuss.elastic.co/u/jxz)\
**Post date:** [September 21, 2017, 9:32pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/3 "2017-09-21T21:32:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 21, 2017, 10:02pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/4 "2017-09-21T22:02:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jxz](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jxz](https://discuss.elastic.co/u/jxz)\
**Post date:** [September 21, 2017, 11:20pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/5 "2017-09-21T23:20:03Z")

</div>

Thanks David! I will peruse it.

---

<div class="post-metadata">

**Author:** ![jxz](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jxz](https://discuss.elastic.co/u/jxz)\
**Post date:** [September 22, 2017, 12:25am UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/6 "2017-09-22T00:25:43Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 22, 2017, 1:45am UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/7 "2017-09-22T01:45:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 20, 2017, 1:55am UTC](https://discuss.elastic.co/t/unable-to-connect-to-elasticsearch-from-another-machine/101392/8 "2017-10-20T01:55:53Z")

</div>

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