title: Mac nginx: [emerg] bind() to 0.0.0.0:8000 failed (48: Address already in use)
body: <p>I am using Nginx to run both the frontend and backend from the same PC.</p>
  <p>Frontend: React   (localhost:3000)</p>
  <p>Backend : GO-Lang (localhost:8080)</p>
  <p>You can expect <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="nofollow noreferrer">CORS</a> error when you try to access BE APIs from your FE code.</p>
  <p>To overcome this I used nginx to create proxies for FE and BE on Different routes but on the same port (localhost:8000)</p>
  <p>FE: /</p>
  <p>BE: /server</p>
  <p>nginx.conf </p>
  <pre><code>upstream server {
  server localhost:8080;
  }
  
  upstream client {
  server localhost:3000;
  }
  
  server {
      listen 8000;
      server_name localhost;
  
      location / {
          proxy_pass http://client;
      }
  
      location ~ /server/(?&lt;section&gt;.*) {
          rewrite ^/server/(.*)$ /$1 break;
  
          proxy_pass http://server;
         
      }
  }
  </code></pre>
  <p>I stopped the nginx with <code>sudo nginx -s stop</code></p>
  <p>Closed terminal</p>
  <p>Quit terminal completely</p>
  <p>But didn't shut down my PC</p>
  <ol>
  <li><p>Today I tried some other configs with the same port (8000) and got the error mentioned in the title.</p>
  </li>
  <li><p>So used a different port everything worked as expected.</p>
  </li>
  <li><p>But when I reverted my config to the above config again. It is showing the error mentioned in the title.</p>
  </li>
  </ol>
  <p><strong>The problem</strong></p>
  <ol>
  <li><p>What I observed is all the ports I used in step 2 are occupied now and I am not able to use them although I have stopped all the servers earlier.</p>
  </li>
  <li><p>After reverting back to the initial config even though the port I am trying to use is 8000 it still says that the port is occupied.</p>
  </li>
  </ol>
  <p><strong>How can I use my port 8000 again?</strong></p>