'django development server, how to stop it when it run in background?
I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?
Solution 1:[1]
One liner..
pkill -f runserver
Solution 2:[2]
well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~
Solution 3:[3]
Try this
lsof -t -i tcp:8000 | xargs kill -9
Solution 4:[4]
Ctrl+c should work. If it doesn't Ctrl+/ will force kill the process.
Solution 5:[5]
As far as i know ctrl+c or kill process is only ways to do that on remote machine. If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.
Solution 6:[6]
We can use the following command.
-> netstat -ntlp
then we will get number of process running with PID, find our python server PID and Kill process.
-> kill -9 PID
Solution 7:[7]
From task manager you can end the python tasks that are running.
Now run python manage.py runserver from your project directory and it will work.
Solution 8:[8]
Programmatically using a .bat script in Command Prompt in Windows:
@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
)
gives
SUCCESS: The process with PID 5104 has been terminated.
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 | archit gupta |
| Solution 2 | bricks |
| Solution 3 | Peter Wauyo |
| Solution 4 | timotaoh |
| Solution 5 | wolendranh |
| Solution 6 | Willie Cheng |
| Solution 7 | Ramandeep Singh |
| Solution 8 | Alfred Wallace |

