# RestClient Connection reset by peer

**URL:** <https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134>\
**Category:** Elasticsearch\
**Created:** [June 1, 2020, 8:32am UTC](https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134 "2020-06-01T08:32:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmj765](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wmj765](https://discuss.elastic.co/u/wmj765)\
**Post date:** [June 1, 2020, 8:32am UTC](https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134/1 "2020-06-01T08:32:30Z")

</div>

Hi , when using RestHighLevelClient , often the requests to Elasticsearch (index search, index requests etc) fail due to connection problems.

```
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(FileDispatcherImpl.java) ~[na:1.8.0_252]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:377)
at org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:231) ~[httpcore-nio-4.4.11.jar:4.4.11]
at org.apache.http.impl.nio.codecs.AbstractMessageParser.fillBuffer(AbstractMessageParser.java:136)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:241)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81) ~[httpasyncclient-4.1.4.jar:4.1.4]
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114) ~[httpcore-nio-4.4.11.jar:4.4.11]
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
... 1 common frames omitted

Wrapped by: java.io.IOException: Connection reset by peer
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:793) ~[elasticsearch-rest-client-7.3.2.jar:7.3.2]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:218)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:205)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1454) ~[elasticsearch-rest-high-level-client-7.3.2.jar:7.3.2]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_252]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

```

and could not find any errro logs in elastic

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [June 1, 2020, 8:41am UTC](https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134/2 "2020-06-01T08:41:37Z")

</div>

Hi @wmj765

The exception you're seeing

> [@wmj765](#):
>
> ```auto
> java.io.IOException: Connection reset by peer
> 
> ```

is caused by a forceful connection termination (`RST`). Elasticsearch itself does not RST HTTP connections (or any other connections for that matter) itself. Likely another piece of your network infrastructure (firewall/proxy/switch/router/...) that sits between your client and Elasticsearch is closing the connection here.

---

<div class="post-metadata">

**Author:** ![wmj765](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wmj765](https://discuss.elastic.co/u/wmj765)\
**Post date:** [June 1, 2020, 11:17am UTC](https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134/3 "2020-06-01T11:17:10Z")

</div>

OK , Thanks ,got it

---

<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 29, 2020, 11:17am UTC](https://discuss.elastic.co/t/restclient-connection-reset-by-peer/235134/4 "2020-06-29T11:17:15Z")

</div>

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