Last Updated: January 28, 2019
·
2.73K
· wkjagt

Django dev server in vagrant

If you want to run Django in a vm (ideally using Vagrant), you may run into a problem when you follow the getting started guide in the documentation where you can't access your Django site from your host machine's browser. The solution is pretty simple, and actually present in the documentation, but you need to dig a little deeper. From the documentation:

Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).

(https://docs.djangoproject.com/en/dev/ref/django-admin/)

So instead of running:

python manage.py runserver 8080

run

python manage.py runserver [::]:8080

and you're good to go.