title: Nodemon: Error: listen EADDRINUSE: address already in use :::5000
body: <p>I'm creating a project and using nodejs, express for the backend.
  Everything works fine but as I make any change in the file, nodemon is unable to restart the server due to following error:</p>
  <p><code>Error: listen EADDRINUSE: address already in use :::5000</code></p>
  <p><strong>index.js:</strong></p>
  <pre><code>const express = require(&quot;express&quot;);
  const morgan = require(&quot;morgan&quot;);
  const mongoose = require(&quot;mongoose&quot;);
  const cookieParser = require(&quot;cookie-parser&quot;);
  const session = require(&quot;express-session&quot;);
  const FileStore = require(&quot;session-file-store&quot;)(session);
  const dotenv = require(&quot;dotenv&quot;);
  var passport = require(&quot;passport&quot;);
  
  dotenv.config();
  
  const PORT = process.env.PORT || 5000;
  
  const app = express();
  
  .....
  
  app.listen(PORT, () =&gt; console.log(`Server listening on port ${PORT}!`));
  </code></pre>
  <p><strong>package.json</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;name&quot;: &quot;chat-app-backend&quot;,
    &quot;version&quot;: &quot;0.0.0&quot;,
    &quot;private&quot;: true,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;node index.js&quot;,
      &quot;dev&quot;: &quot;nodemon --ignore 'sessions/' index.js&quot;
    },
    &quot;dependencies&quot;: {
      &quot;bcryptjs&quot;: &quot;^2.4.3&quot;,
      &quot;cookie-parser&quot;: &quot;^1.4.5&quot;,
      &quot;cors&quot;: &quot;^2.8.5&quot;,
      &quot;debug&quot;: &quot;~2.6.9&quot;,
      &quot;dotenv&quot;: &quot;^8.2.0&quot;,
      &quot;express&quot;: &quot;~4.16.0&quot;,
      &quot;express-session&quot;: &quot;^1.17.0&quot;,
      &quot;http-errors&quot;: &quot;~1.6.2&quot;,
      &quot;jade&quot;: &quot;~1.11.0&quot;,
      &quot;jsonwebtoken&quot;: &quot;^8.5.1&quot;,
      &quot;mongoose&quot;: &quot;^5.9.4&quot;,
      &quot;morgan&quot;: &quot;~1.9.0&quot;,
      &quot;passport&quot;: &quot;^0.4.1&quot;,
      &quot;passport-jwt&quot;: &quot;^4.0.0&quot;,
      &quot;passport-local&quot;: &quot;^1.0.0&quot;,
      &quot;passport-local-mongoose&quot;: &quot;^6.0.1&quot;,
      &quot;session-file-store&quot;: &quot;^1.4.0&quot;,
      &quot;uuid&quot;: &quot;^7.0.2&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;nodemon&quot;: &quot;^2.0.2&quot;
    }
  }
  </code></pre>
  <p>I've to explicitly kill the server from the terminal every time, which is not the optimal solution.
  I tried several things, but none are working. Even found some issue in nodemon GitHub issue page, but there also I couldn't find anything.</p>
  <p>I'm also adding the output of <strong>lsof -i:5000</strong>, even if server I'm closing the server - *<em>node    31625 rishav   20u  IPv6 5300049      0t0  TCP <em>:5000 (LISTEN)</em></em></p>