title: Node.js REQUEST throwing ECONNREFUSED after a few attempts
body: <p>I am using the below code:</p>
  
  <pre><code>async function validateMOData(data, callback) {
      success('Validation started');
      let a = 0;
      let i = data.length;
      console.log('length of array', i);
      while (i--) {
          a = a + 1;
          console.log('Loop Count', a);
          console.log(data[i]);
          let result;
          try {
              result = await checkValidity(data[i]);
              if ((JSON.parse(result.body)).isValid === false) {
                  createErrorLog(data[i].MemberId, data[i].MemberAgreementId, (JSON.parse(result.body)).responseMessage, (JSON.parse(result.body)).responseCode, 'x', data[i].CsvFileName)
                  deleteFaultyData(data[i].Id);
                  data.splice(i, 1);
              }
          } catch (err) {
              console.log(err);
          }
      }
      success('validation ended');
      callback(data);
  }
  function checkValidity(record) {
      return new Promise((resolve, reject) =&gt; {
          let validityCheckUrl = `${constants.USER_INTERFACE.SERVER_URL_PREFIX}validateMemberData/?memberId=${record.MemberId}&amp;memberAgreementId=${record.MemberAgreementId}`;
          request({ url: validityCheckUrl, pool: { maxSockets: 10 } }, (error, response, body) =&gt; {
              if (error) {
                  reject(error);
              } else {
                  resolve(response, body);
              }
          });
      });
  
  }
  </code></pre>
  
  <p>After a few iterations in the while loop, the <code>checkValidity</code> method starts to throw the below error :</p>
  
  <pre><code>{ Error: connect ECONNREFUSED IP:port
  at Object._errnoException (util.js:1022:11)
  at _exceptionWithHostPort (util.js:1044:20)
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: 'IP',
  port: port }
  </code></pre>
  
  <p>This error does not come in the first request but after a few requests. Can anyone help? Am i missing anything?</p>
  
  <p><strong>NOte</strong>: This code run on AWS lambda and checkValidity connects to a Node.js server deployed on EC2</p>