title: Flask allows multiple server instances to listen on the same port
body: <p>I have been using flask and noticed this unusual behavior. </p>
  
  <p>My flask application is set to run on port 5000 in my machine (It has only one network card). </p>
  
  <p>When I attempt to start more than one instance of the same flask application in my machine.</p>
  
  <p><strong>What I Expected</strong>:</p>
  
  <p>A port address in use error when attempting to start the next instance bound on the same port.</p>
  
  <p><strong>What actually happened</strong>: </p>
  
  <p>They all start successfully and bind to the same port. This kind of behavior is not expected with most conventional servers that I have used.
  Thankfully however, only one process out of the 'n' processes is triggered when a REST API call is made to the server.</p>
  
  <p>Operating System: Windows</p>
  
  <p>Can someone please explain why this behavior occurs, and how can I ensure that flask doesn't start the process successfully in such a case.</p>
  
  <p>netstat -aon | find "5000"</p>
  
  <p>TCP    127.0.0.1:5000         0.0.0.0:0              LISTENING       37036<br>
  TCP    127.0.0.1:5000         0.0.0.0:0              LISTENING       5024<br>
  TCP    127.0.0.1:5000         0.0.0.0:0              LISTENING       61684</p>
  
  <p>The above are the 3 process that are running in parallel. </p>
  
  <p>Additional Notes: </p>
  
  <ol>
  <li>I am using this in a virtualenv.  </li>
  <li><p>The way I have written my flask invocation.  </p>
  
  <pre><code>if __name__ == "__main__":
  main()
  app.run(port=5000)
  </code></pre></li>
  <li><p>Running the code as <code>python3 &lt;filename&gt;.py</code> at the command prompt.</p></li>
  </ol>