Vagrant is not forwarding when I run django runserver on ssh

∥☆過路亽.° 提交于 2019-12-31 08:44:08

问题


I created a Vagrant Ubuntu (lucid32) box with Python & Django. My idea is start the VM, log into it with vagrant ssh, and then start Django by running:

manage.py runserver

which defaults to port 8000. The problem is that I can not access the Django server from the host's browser at http://127.0.0.1:8000. What can I do?


回答1:


You need to bind the server to the external IP with:

manage.py runserver 0.0.0.0:8000



回答2:


First, you need to do port forwarding in Vagrant file.

config.vm.network "forwarded_port", guest: 8000, host: 8000

Then you need to restart/reload your vangrant vm

vagrant reload

Now ssh to your vm and run django server as follows

python manage.py runserver 0.0.0.0:8000


来源:https://stackoverflow.com/questions/15255203/vagrant-is-not-forwarding-when-i-run-django-runserver-on-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!