title: Error: listen EADDRINUSE: address already in use :::3001 [Nodemon, Node.js]
body: <p>I have been using a Windows 10 laptop for years and now I changed to a MacBook. I pulled some of my code from Github (using exactly the same code for my server) and Nodemon doesn't want to restart the server automatically when I hit save. What's going on?</p>
  <p>index.js:</p>
  <pre><code>const express = require(&quot;express&quot;);
  const path = require(&quot;path&quot;);
  const cors = require(&quot;cors&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  const http = require(&quot;http&quot;);
  
  const app = express();
  const server = http.createServer(app);
  
  app.use(express.json({ extended: false, limit: &quot;5mb&quot; }));
  app.use(cors());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  if (process.env.NODE_ENV === &quot;production&quot;) {
      app.use(express.static(&quot;client/build&quot;));
      app.get(&quot;*&quot;, (req, res) =&gt;
          res.sendFile(path.resolve(__dirname, &quot;client&quot;, &quot;build&quot;, &quot;index.html&quot;))
      );
  }
  
  const PORT = process.env.PORT || 3001;
  
  server.listen(PORT, () =&gt; console.log(`Server started on port ${PORT}.`));
  </code></pre>
  <p>I make some changes then hit save then I get this error:</p>
  <pre><code>events.js:292
  [0]       throw er; // Unhandled 'error' event
  [0]       ^
  [0] 
  [0] Error: listen EADDRINUSE: address already in use :::3001
  </code></pre>
  <p>Package.json:</p>
  <pre><code>&quot;scripts&quot;: {
          &quot;start&quot;: &quot;node index.js&quot;,
          &quot;server&quot;: &quot;nodemon index.js&quot;,
          &quot;client&quot;: &quot;npm start --prefix client&quot;,
          &quot;dev&quot;: &quot;concurrently \&quot;npm run server\&quot; \&quot;npm run client\&quot;&quot;
  },
  </code></pre>
  <p>What I want is that when I hit save, it saves everthing then restarts the server on the same port. Everything is automatic. I do not want to kill the server manually each time I save. This one worked on Windows 10 and now it doesn't on my MacBook...</p>