# No connection could be made because the target machine actively refused

**URL:** <https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175>\
**Category:** Elasticsearch\
**Created:** [May 1, 2017, 7:10pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175 "2017-05-01T19:10:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fryette](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@Fryette](https://discuss.elastic.co/u/Fryette)\
**Post date:** [May 1, 2017, 7:10pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/1 "2017-05-01T19:10:31Z")

</div>

I have an issue

I tried to use elasticsearch, but have an issue  
Invalid NEST response built from a unsuccessful low level call on PUT: /mytweetindex/tweet/1  
Audit trail of this API call:

- [1] BadRequest: Node: [http://127.0.0.1:9200/](http://127.0.0.1:9200/) Took: 00:00:01.0227803  
OriginalException: System.Net.WebException: Unable to connect to the remote server ---\> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 192.168.100.34:9200  
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)  
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)  
--- End of inner exception stack trace ---  
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)  
at System.Net.HttpWebRequest.GetRequestStream()  
at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\Projects\elastic\net-5\src\[Elasticsearch.Net](http://Elasticsearch.Net)\Connection\HttpConnection.cs:line 149  
Request:  
\<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>  
Response:  
\<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>

this is code  
private static ElasticClient client;

```
	public void StartClient()
	{
		var node = new Uri("http://192.168.100.34:9200");
		var settings = new ConnectionSettings(node);
		client = new ElasticClient(settings);

		var tweet = new Tweet
		{
			Id = 1,
			User = "kimchy",
			PostDate = new DateTime(2009, 11, 15),
			Message = "Trying out NEST, so far so good?"
		};

		var response = client.Index(tweet, idx => idx.Index("mytweetindex"));
	}
}`

```

I disable fairwall and windows defender  
Also I tried open app as administrator

---

<div class="post-metadata">

**Author:** ![mmichaels01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmichaels01/32/22513_2.png) [@mmichaels01](https://discuss.elastic.co/u/mmichaels01)\
**Post date:** [May 1, 2017, 8:39pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/2 "2017-05-01T20:39:17Z")

</div>

Is your Elasticsearch instance running and configured without any security?

What happens when you navigate to localhost:9200 in your browser?

---

<div class="post-metadata">

**Author:** ![Fryette](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@Fryette](https://discuss.elastic.co/u/Fryette)\
**Post date:** [May 2, 2017, 9:07am UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/3 "2017-05-02T09:07:42Z")

</div>

Yes, exactly, I forgot about run elasticsearch instance  
So, right now I trying to start it, but it a bit difficult. I tried to start but file, but it closed in a moment.  
Maybe you can help me with run elasticsearch bat file?

---

<div class="post-metadata">

**Author:** ![mmichaels01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmichaels01/32/22513_2.png) [@mmichaels01](https://discuss.elastic.co/u/mmichaels01)\
**Post date:** [May 2, 2017, 11:16pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/4 "2017-05-02T23:16:16Z")

</div>

Execute it from commandline so you can see the message it gives.

Open a command prompt in administrator mode, change your directory to wherever the launch script is and execute it. Does it log an error message?

---

<div class="post-metadata">

**Author:** ![swu](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@swu](https://discuss.elastic.co/u/swu)\
**Post date:** [May 5, 2017, 5:09pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/5 "2017-05-05T17:09:18Z")

</div>

I got the similar error , eventhough the elastic search is running well in our product box. please help.

"Invalid NEST response built from a unsuccessful low level call on GET: /apifrecord360%2A/\_settings\r\n# Audit trail of this API call:\r\n - [1] BadResponse: Node: [http://XXXXXXX.cloudapp.azure.com:9200/](http://XXXXXXX.cloudapp.azure.com:9200/) Took: 00:00:21.4285309\r\n# OriginalException: System.Net.WebException: Unable to connect to the remote server ---\> 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 xx.xxx.xx.xx:8080\r\n at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)\r\n at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)\r\n --- End of inner exception stack trace ---\r\n at System.Net.HttpWebRequest.GetResponse()\r\n at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\Projects\elastic\net-5\src\[Elasticsearch.Net](http://Elasticsearch.Net)\Connection\HttpConnection.cs:line 164\r\n# Request:\r\n\<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>\r\n# Response:\r\n\<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>\r\n"

the following is my connectsettings:

node = new Uri((Properties.Settings.Default.URI));  
var settings = new ConnectionSettings(node).RequestTimeout(TimeSpan.FromMinutes(2));  
client = new ElasticClient(settings);

---

<div class="post-metadata">

**Author:** ![mmichaels01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmichaels01/32/22513_2.png) [@mmichaels01](https://discuss.elastic.co/u/mmichaels01)\
**Post date:** [May 5, 2017, 5:44pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/6 "2017-05-05T17:44:39Z")

</div>

So you've switched to pointing it towards your remote Elastic rather than local?

Is it possible there are some firewall rules you aren't accounting for? This seems like it could be a networking issue moreso than a problem with Elasticsearch configuration.

I would see if you can resolve the issue by making sure your network rules are configured properly and just hitting the node with a GET on the root via some API testing tool like postman. Make sure you include whatever auth you need in the request.

```
GET HTTP/1.1
Host: {{ElasticUrl}}
Content-Type: application/json
Cache-Control: no-cache

```

Where **{{ElasticUrl}}** is pointing to your environment. Add basic auth if you've configured it in such a way.

Once you see a response similar to this, go back to configuring your NEST client:

```
{
  "name": "xxxxx",
  "cluster_name": "xxxxx",
  "cluster_uuid": "xxxxx",
  "version": {
    "number": "5.3.1",
    "build_hash": "5f9cf58",
    "build_date": "2017-04-17T15:52:53.846Z",
    "build_snapshot": false,
    "lucene_version": "6.4.2"
  },
  "tagline": "You Know, for Search"
}
```

---

<div class="post-metadata">

**Author:** ![swu](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@swu](https://discuss.elastic.co/u/swu)\
**Post date:** [May 5, 2017, 7:45pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/7 "2017-05-05T19:45:48Z")

</div>

thank you for your quick response!

when i run {{ElasticUrl}} , it turned the small jason file, the pattern is similar as you shown me.

debugging the code, the error is pointing to the line " var result = client.GetIndexSettings(request);"

the following is the code

var request = new GetIndexSettingsRequest(pattern + "\*", null); //pattern is the name of index

///if we find any matching indexes, keep going

if (request != null)

{

```
     ///Pulls all settings for all the indexes that match the pattern.  
     var result = client.GetIndexSettings(request);
     ...

```

}

is that limitation for GetIndexSettings in 5.X version? wierd, it works in my local, but not in prod environment. both using 5.2.2 version now

thanks,

---

<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:** [June 2, 2017, 7:48pm UTC](https://discuss.elastic.co/t/no-connection-could-be-made-because-the-target-machine-actively-refused/84175/8 "2017-06-02T19:48:34Z")

</div>

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