title: Node.js hangs on HTTP requests
body: <p>I am currently developing an Electron application which listens to the TCP socket and sends requests to the REST server after receiving data.</p>
  
  <p>For test purposes I use the following code:</p>
  
  <pre><code>const net = require('net');
  const fetch = require('node-fetch');
  
  const server = net.createServer(connection =&gt; {
    connection.setEncoding('utf8');
    connection.on('data', data =&gt; {
      handleData(data).then(() =&gt; connection.end());
    });
  });
  
  const handleData = data =&gt; {
    return Promise.resolve()
      .then(() =&gt; test(1))
      .then(() =&gt; test(2))
      .then(() =&gt; test(3))
      .then(() =&gt; test(4))
      .then(() =&gt; test(5));
  };
  
  const test = id =&gt; {
    return fetch(`https://server.domain.name/api/v1/software/${id}`)
      .then(response =&gt; response.json())
      .then(json =&gt; {
        console.log(json);
      });
  };
  
  const socketHost = '0.0.0.0';
  const socketPort = 1337;
  server.listen(socketPort, socketHost);
  </code></pre>
  
  <p>This code hangs on the first request. According to the <code>tcpdump</code>, request does not even leave my machine. Strange thing is when I user IP address in URL instead of domain name, requests work fine. So, I suppose this problem is somehow related to DNS lookup. Any ideas?</p>
  
  <p><strong>Edit:</strong> When running this code in pure Node.js the issue does not appear.</p>
  
  <p><strong>Edit:</strong> This issue only appears on Linux.</p>