title: Load balancing using PM2
body: <p>I have problems load balancing a Node.js (10.32) simple script using PM2, on a machine with two CPU cores.</p>
  
  <p>The script is the following:</p>
  
  <pre><code>var http = require('http');
  var server = http.createServer(function (req, res) {
    res.writeHead(200, {"Content-Type": "text/plain"});
    res.end("Hello World\n");
  });
  server.listen(81);
  </code></pre>
  
  <p>If I run <code>pm2 start -i max script.js</code>, the two child processes seem to launch successfully (according to <code>pm2 list</code>), but requests to <code>http://localhost:81</code> hang.</p>
  
  <p>If I run <code>pm2 start -i max -x script.js</code>, the first child process is successfully launched, but the second restarts forever (with an EADDRINUSE error).</p>
  
  <p>I checked with <code>lsof</code> and the port 81 is not used before running PM2.</p>