title: Node.js HTTP GET “ECONNRESET” Error on read
body: <p>I've read all the related issues on SO and GitHub about this error and none of them seem to address this situation.</p>
  
  <p>When I run the following code:</p>
  
  <pre><code>response = await axios.get('http://localhost:8082/panda, {
    httpAgent: new http.Agent({ keepAlive: true, keepAliveMsecs: 10000 })
  });
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>{ Error: socket hang up
      at createHangUpError (_http_client.js:345:15)
      at Socket.socketOnEnd (_http_client.js:437:23)
      at emitNone (events.js:110:20)
      at Socket.emit (events.js:207:7)
      at endReadableNT (_stream_readable.js:1059:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }
  { Error: read ECONNRESET
      at _errnoException (util.js:1019:11)
      at TCP.onread (net.js:608:25)
    code: 'ECONNRESET',
    errno: 'ECONNRESET',
    syscall: 'read',
    etc...
  </code></pre>
  
  <p>There's no stack trace beyond the <code>onread</code> call so it's unclear how I can get any additional information beyond the <code>ECONNRESET</code> error code (-54) passed to the <code>onread</code> method in net.js</p>
  
  <p>This issue happens with every request - it is not intermittent.</p>
  
  <p>A few observations:</p>
  
  <ul>
  <li><strong>when making the same request from chrome or postman the request does NOT fail</strong></li>
  <li>attempting to reproduce a successful request from Chrome, by using the same headers, fails</li>
  <li>setting the accept header to use 'gzip', etc.. does not help - I have tried all the recommendations including some weird ones like setting the content length and adding a body to the request despite this being a GET request
  
  <ul>
  <li>the error always appears in net.js, but happens with both the request and axios libraries</li>
  </ul></li>
  </ul>
  
  <p>Here's the interesting part - <strong>I can only seem to reproduce this problem reliably when I am hosting the server locally</strong>. I am able to reach the dev instance or run the server in vagrant, via a docker container, without issue.</p>
  
  <p>I am running macOS Sierra 10.12.6 if that makes any difference. The server is written in Java and uses the Spring framework. Here is the <code>RestTemplate</code> configuration I'm using for HTTP calls:</p>
  
  <pre><code>@Bean
  public RestTemplate restTemplate() {
      //request timeout
      int timeout = 5000;
  
      //Connection Pooling factory with timeouts to prevent disastrous request responses
      HttpComponentsClientHttpRequestFactory cf = new HttpComponentsClientHttpRequestFactory();
      cf.setReadTimeout(timeout);
      cf.setConnectTimeout(timeout);
      cf.setConnectionRequestTimeout(timeout);
  
      return new RestTemplate(cf);
  }
  </code></pre>
  
  <p>I've tried messing around with these settings with no luck.</p>
  
  <p>Any ideas?</p>