title: ERR_SERVER_ALREADY_LISTENING error with Node.JS app but only with 10.2.1?
body: <p>I have a Node.JS app running on Ubuntu Linux 18.04 (Bionic).  It runs fine on Node.JS version 8.11.1; no errors at all.  But when I try to run it with 10.2.1, I get the following error the instant I execute the <em>listen()</em> method on the server I create:</p>
  
  <pre><code>    net.js:1416
          throw new ERR_SERVER_ALREADY_LISTEN();
          ^
  
      Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has been called more than once without closing.
          at Server.listen (net.js:1416:11)
          at Object.&lt;anonymous&gt; (./web-site/bin/www:56:8)
          at Module._compile (internal/modules/cjs/loader.js:699:14)
          at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
          at Module.load (internal/modules/cjs/loader.js:612:32)
          at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
          at Function.Module._load (internal/modules/cjs/loader.js:543:3)
          at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
          at startup (internal/bootstrap/node.js:238:19)
          at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
      Waiting for the debugger to disconnect...
  </code></pre>
  
  <p>I triple-checked this but I am only calling the <em>listen()</em> method once.  Besides, if that was really the problem, the code wouldn't work with older versions of Node.JS.</p>
  
  <p>Can anyone think of why this is happening and how I might fix it?</p>
  
  <p>Here is the code for my <em>bin/www</em> file.  This is the file that is launched in my debug configuration when I run the app:</p>
  
  <pre><code>#!/usr/bin/env node
  
  /**
   * Web start file that supports SSL and listens for traffic on port 7300.
   */
  
  /**
   * Module dependencies.
   */
  
  var app = require('../app');
  var debug = require('debug')('aux:server');
  
  /**
   * Get port from environment and store in Express.  If not, use port 3000.
   */
  
  var port = normalizePort(process.env.PORT || '3000');
  app.set('port', port);
  
  /**
   * Create the HTTPS server.
   */
  
  var fs = require('fs');
  var https = require('https');
  
  // Get the location of the private key and fullchain files for SSL support
  //  from the environment.
  var privkeyPath = process.env.PRIVKEY_PATH;
  var fullchainPath = process.env.FULLCHAIN_PATH;
  
  // Validate them.
  if (!fs.existsSync(privkeyPath))
      throw new Error("Invalid private key file path: " + privkeyPath);
  
  if (!fs.existsSync(fullchainPath))
      throw new Error("Invalid fullchain file path: " + fullchainPath);
  
  var options = {
      key: fs.readFileSync(privkeyPath),
      cert: fs.readFileSync(fullchainPath),
      requestCert: true,
      rejectUnauthorized: true
  };
  
  var server = https.createServer(options, app).listen(port, function(){
      console.log("Certificate enabled express server listening on port " + port);
  });
  
  
  /**
   * Listen on provided port, on all network interfaces.
   */
  
  server.listen(port);
  server.on('error', onError);
  server.on('listening', onListening);
  
  /**
   * Normalize a port into a number, string, or false.
   */
  
  function normalizePort(val) {
      var port = parseInt(val, 10);
  
      if (isNaN(port)) {
          // named pipe
          return val;
      }
  
      if (port &gt;= 0) {
          // port number
          return port;
      }
  
      return false;
  }
  
  /**
   * Event listener for HTTP server "error" event.
   */
  
  function onError(error) {
      if (error.syscall !== 'listen') {
          throw error;
      }
  
      var bind = typeof port === 'string'
          ? 'Pipe ' + port
          : 'Port ' + port;
  
      // handle specific listen errors with friendly messages
      switch (error.code) {
          case 'EACCES':
              console.error(bind + ' requires elevated privileges');
              process.exit(1);
              break;
          case 'EADDRINUSE':
              console.error(bind + ' is already in use');
              process.exit(1);
              break;
          default:
  
          throw error;
      }
  }
  
  /**
   * Event listener for HTTP server "listening" event.
   */
  
  function onListening() {
      var addr = server.address();
      var bind = typeof addr === 'string'
          ? 'pipe ' + addr
          : 'port ' + addr.port;
  
      debug('Listening on ' + bind);
  }
  </code></pre>