'How to stop the Django development server on windows
I found here answers how to stop the Django Server on Linux but not on windows.
Do I really need to restart my machine ?
Solution 1:[1]
Open Resource Monitor in the Command Prompt using the command resmon. At the "Listening Ports", find the port you're using. See Resource Monitor here. 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. See Task Manager here
Solution 2:[2]
In your terminal, spam ctrl+c
a few times.
Solution 3:[3]
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```
Solution 4:[4]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | angelacpd |
Solution 2 | CyberHavenProgramming |
Solution 3 | Alfred Wallace |
Solution 4 |