• Uncategorized

About python : Running-standalone-Django-runserver

Question Detail

I have set up a VPS and installed Django on it.
I’ve installed Django within the virtual environment i created using python3 -m venv env and activated via source env/bin/activate.

In order to run the Django built-in webserver i need to run python3 manage.py runserver.

The webserver runs until i close the SSH session, so how can i run a standalone webserver without being dependent on the SSH session. (And also taking advantage of being ran inside the virtual environment)?

Question Answer

One of the simplest way to do this is use docker.
Example how to setup docker with django:

Or you can solve this with screen in linux system, but remember this is not for production use:

Running it as a background process is a quick solution.

nohup python3 manage.py runserver &

If you really want to take it to next level then consider running it using one of the Django deployment options which are very well documented by Django team.


I have used Gunicorn with nginx server running to front it so that nginx can server static content. you can find details here.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.