6đź‘Ť
If your network is configured correctly and your django application with
python manage.py runserver 0.0.0.0:8000
and you still can’t access your django app from the VM host there is almost certainly a firewall issue. The solution above is good if you are running iptables.
I deployed CentOS 7 on a virtualbox VM from a Windows 7 host. I didn’t know that this distribution uses firewalld, not iptables to control access.
if
ps -ae | grep firewall
returns something like
602 ? 00:00:00 firewalld
your system is running firewalld, not iptables. They do not run together.
To correct you VM so you can access your django site from the host use the commands:
firewall-cmd –zone=public –add-port=8000/tcp –permanent
firewall-cmd –reload
Many thanks to pablo v for pointing this out in the post "Access django server on virtual Machine".
4đź‘Ť
the host’s “127.0.0.1” is not the same as the guest’s “127.0.0.1”. Per default the command
python manage.py runserver
listens only to the guest’s localhost. You should be able to test it from within the vm (use “vagrant ssh” to login) and run
curl -I http://127.0.0.1:8000/
The host as a different IP. To access the development server from the host you have to start it without ip restriction:
python manage.py runserver 0.0.0.0:8000
Yes:
python manage.py runserver [::]:8000
should be the same. But that’s IPv6 syntax AFAIK. Are you sure that the “manage.py runserver” command supports IPv6 by default? I’ve never used ipv6 addresses w/ django, but looking at the source (https://github.com/django/django/blob/master/django/core/management/commands/runserver.py) there seams to be a flag that the default to False (“–ipv6”). Perhaps that’s the “real” problem?
Regards,
3đź‘Ť
For a similar problem,
This command worked like a charm for me
python manage.py runserver [::]:8001
- [Django]-Django CreateView : Append ForeignKey to CustomForm Data
- [Django]-Invalid embedded document instance provided to an EmbeddedDocumentField
- [Django]-Override Django User Manager to only return active users in queries
0đź‘Ť
Check your iptables, and stop it. Ubuntu commonly does not open the iptables when it starts.
- [Django]-How to use a different database for Heroku review apps?
- [Django]-Django official tutorial for the absolute beginner, absolutely failed!
- [Django]-Django handle Annonymous users