Reputation: 4008
I found here answers how to stop the Django Server on Linux but not on windows.
Do I really need to restart my machine ?
Upvotes: 3
Views: 10113
Reputation: 724
Open Resource Monitor in the Command Prompt using the command resmon.
At the "Listening Ports", find the port you're using.
In my case, is Port 8000.
Get the PID, in this example is 20132.
Open Task Manager, go to Tab Details, find the PID and end the task.
Upvotes: 5
Reputation: 1
Just Press ctr+C instead of CTRL+BREAK (There is no BREAK key present on keyboard) . To fix unapplied migration I wanted to quit server
Upvotes: -1
Reputation: 1
Edit1: On windows I used 'Run manage.py Task' in pycharm and I simply closed pycharm and the port is not in use anymore
Edit2: If you are using 'Run manage.py Task' in pycharm, check this: My picture of terminating server There's a in-built option for stopping the server in pycharm
Upvotes: -1
Reputation: 2014
For those looking for a programmatic solution, closing port 8000
and all associated connections (there may be more than one) can be done with a .bat
script:
@ECHO OFF
SET /A port=8000
FOR /F "tokens=5" %%T IN ('netstat -ano ^| findstr :%port%') DO (
SET /A processid=%%T
TASKKILL /PID %%T /F
)
Note that the CMD
line netstat -ano ^| findstr :%port%
is used to list the connections using port 8000
:
>netstat -ano | findstr :8000
TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING 10920
TCP 10.0.1.11:8000 10.0.1.11:14813 ESTABLISHED 10920
TCP 10.0.1.11:8000 10.0.1.11:14814 ESTABLISHED 10920
TCP 10.0.1.11:8000 10.0.1.11:14815 ESTABLISHED 10920
TCP 10.0.1.11:14813 10.0.1.11:8000 ESTABLISHED 2628
TCP 10.0.1.11:14814 10.0.1.11:8000 ESTABLISHED 2628
TCP 10.0.1.11:14815 10.0.1.11:8000 ESTABLISHED 2628```
Upvotes: 1