Django server killed frequently
From the documentation on the django development server
https://docs.djangoproject.com/en/1.10/ref/django-admin/
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone
through security audits or performance tests. (And that’s how it’s
gonna stay. We’re in the business of making Web frameworks, not Web
servers, so improving this server to be able to handle a production
environment is outside the scope of Django.)
Of course it get's killed frequently, it's not designed to be kept running for long hours. Set up one of the standard solutions such as gunicorn+nginx or apache+uswgi etc.
django development server, how to stop it when it run in background?
The answer is findable via Google -- and answered in other forums. Example solution is available on the Unix & Linux StackExchange site.
To be explicit, you could do:
ps auxw | grep runserver
This will return the process and its respective PID, such as:
de 7956 1.8 0.6 540204 55212 ? Sl 13:27 0:09 /home/de/Development/sampleproject/bin/python ./manage.py runserver
In this particular case, the PID is 7956
. Now just run this to stop it:
kill 7956
And to be clear / address some of the comments, you have to do it this way because you're running the development server in the background (the &
in your command). That's why there is no "built-in" Django stop option...
django runserver gets killed
Out of trial and error, I found the way to stop runserver from getting killed.
--nothreading actually solved my problem automagically.
so final commands to run dev server is.
django-admin runserver 1.2.3.4:8000 --nothreading
or
python manage runserver 1.2.3.4:8000 --nothreading
Happy I am :-)
Django Server Error: port is already in use
A more simple solution just type sudo fuser -k 8000/tcp
.
This should kill all the processes associated with port 8000.
EDIT:
For osx users you can use sudo lsof -t -i tcp:8000 | xargs kill -9
Related Topics
Python Multiprocessing: Permission Denied
Parsing a Date That Can Be in Several Formats in Python
How to Avoid Having Class Data Shared Among Instances
Why Does Append() Always Return None in Python
Fastest Way to List All Primes Below N
How to Concatenate Items in a List to a Single String
How to Concatenate Two Lists in Python
How to Pass Arguments to a Button Command in Tkinter
Logical Operators For Boolean Indexing in Pandas
How to Terminate Process from Python Using Pid
Python - Is Time.Sleep(N) Cpu Intensive
Get the Cartesian Product of a Series of Lists
Syntax Error on Print With Python 3
Why Is the Output of My Function Printing Out "None"
Error "Microsoft Visual C++ 14.0 Is Required (Unable to Find Vcvarsall.Bat)"