I am on Windows, and run my Django server via manage.py runserver 8001
. When I have already running server and enter the mentioned command again, it starts another server listening the same (8001) port. What I would like to do is to determine if server is already running and stop the execution of the command, or stop the running server and then run the new server.
UPDATE:
I need to do the described things automatically. Throwing an error is also OK.
But why runserver
command is not throwing an error, if the port is already busy?? That's a standard behavior of platforms that I have experience with (Java Tomcat server, PHP) and also on Ubuntu with Django, as this question clarifies.