title: http.request with connect ECONNREFUSED
body: <p>I run following code which is really simple: I create a server listening 9900. Then I wait 1 second (to ensure the server is ready), and issue 1000 requests to this server. I expect all 1000 requests to be finished correctly. Below is my code:</p>
  
  <pre><code>const http = require('http');
  
  // create server
  http.createServer(function(req, res){
      res.end('ok')
  }).listen(9900)
  
  // issue 1000 requests after 1 second
  setTimeout( async function(){
      for(let i=0;i&lt;1000;i++) { // werid: it works well after changing 1000 to 800
          request();
      }
  }, 1000 )
  
  // actually I don't care if the Promise is resolved or rejected,
  // so I don't await or chain then.
  function request() {
      return new Promise((resolve, reject) =&gt; {
          const option = {
              protocol: 'http:',
              host: 'localhost',
              port: 9900,
              path: '/',
              agent: false,
              method: 'GET'
          };
          const req = http.request(option, function(res) {
              res.setEncoding('utf8');
              let body = '';
              res.on('data', (chunk) =&gt; {
                  body += chunk;
              });
              res.on('end', () =&gt; {
                  console.log(body)
                  resolve(body)
              });
          });
          req.on('error', (e) =&gt; {
              console.error(`problem with request: ${e.message}`);
              console.log(e.stack)
              process.exit(1)
          });
          req.end();
      })
  }
  </code></pre>
  
  <p>But I got <code>ECONNREFUSED</code> error, which seems the machine could not establish more socket. The werid thing is if I change the <code>for loop</code> to 800, the error won't show. Is there a potential reason or bug? Thanks.</p>
  
  <pre><code>problem with request: connect ECONNREFUSED 127.0.0.1:9900
  Error: connect ECONNREFUSED 127.0.0.1:9900
      at Object._errnoException (util.js:1024:11)
      at _exceptionWithHostPort (util.js:1046:20)
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  </code></pre>