【发布时间】:2015-04-08 06:36:46
【问题描述】:
我使用的是vagrant Geodjango box,但端口转发对我不起作用。
在盒子上,我跑了:
python manage.py runserver 0.0.0.0:8000
但是http://localhost:8000 和http://localhost:4567 在主机上都找不到任何东西。
在 Vagrant 框中,curl -v 'http://localhost:8000/' 给出通常的:
<h2>Congratulations on your first Django-powered page.</h2>
这表明 Django 运行正常。但在主机上,尝试curl -v 'http://localhost:8000/' 会得到以下输出:
curl: (7) Failed connect to localhost:8000; Connection refused
我的 Vagrantfile 设置了以下端口转发:
config.vm.forward_port 8000, 4567
禁用 Mac 的防火墙无济于事,停止 Apache 也无济于事。我试过在主机上运行lsof -i :8000 并且没有输出,所以我认为没有任何东西在使用该端口。
谁能给点建议?
【问题讨论】:
-
啊,想通了——在
vagrant reload进程的开始,有一个关于端口转发的警告,我没有看到。 Vagrant 重新分配了端口,因此该站点实际上在端口 2201 上运行,http://localhost:2201/工作。