Check if the port is available as first step in runserver

When you start a new Django server with python manage.py run server if the port is already in use, an exception is raised after some processing is already done.
It would make much more sense to have a check at the start itself to save the time of the developer because no matter what if the port is already in use, the server is bound to crash.

Welcome to the forum @DefCon-007

That could be useful, although it would be weak to TOCTOU bugs. How long does your server take to start? We try and optimize how long Django takes to start, but it’s inevitable that the more modules you have, the longer your app takes to load.

Thank you @adamchainz, actually, my server has a lot of other dependencies too which inevitably takes time to start.
I was first going to implement this feature for my server only but later realized, it could be a nice to have feature for Django itself.
I agree with you on TOCTOU bug, if that could be an issue, we can add a flag to check for port availability
before booting up which can be used by the people if they wish.