流浪者端口转发在Mavericks上不起作用 [英] Vagrant port forwarding not working on Mavericks
问题描述
我正在使用无用的Geodjango框,并且端口转发无法正常工作为我.
在盒子上,我已经跑过:
python manage.py runserver 0.0.0.0:8000
但是http://localhost:8000
和http://localhost:4567
都在主机上找不到任何内容.
在无业游民"框中,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
,但没有输出,因此我认为没有任何端口在使用.
有人可以提出任何建议吗?
很高兴看到您自己弄清楚了.
只想在V2 Vagrantfile中添加我的2美分,端口转发代码块如下所示,请尝试使用新的以避免端口冲突(在v1中,我总是很困惑哪个是哪个)./p>
config.vm.forward_port 8000, 4567
正在将访客端口8000转发到主机4567,而不是相反.
在V2格式中,如下图所示,根据我的观点,这一点更加清楚
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end
I'm using a vagrant Geodjango box and port forwarding is not working for me.
On the box, I have run:
python manage.py runserver 0.0.0.0:8000
But http://localhost:8000
and http://localhost:4567
both find nothing on the host machine.
On the Vagrant box, curl -v 'http://localhost:8000/'
gives the usual:
<h2>Congratulations on your first Django-powered page.</h2>
which suggests that Django is running okay. But on the host machine, trying curl -v 'http://localhost:8000/'
gives the following output:
curl: (7) Failed connect to localhost:8000; Connection refused
My Vagrantfile has the following port forwarding set up:
config.vm.forward_port 8000, 4567
Disabling the Mac's firewall does not help and stopping Apache makes no difference. I have tried running lsof -i :8000
on the host machine and there is no output, so I figure nothing is using the port.
Can anyone suggest anything?
Good to see you figured it out yourself.
Just want to add my 2 cents, in V2 Vagrantfile, the port forwarding code block is like below, try to use the new ones so as to avoid port conflicts (back in v1 I always got confused which is which).
config.vm.forward_port 8000, 4567
is forwarding guest port 8000 to host 4567, not the other way around.
In V2 format, it looks like below, which is clearer from my opinion
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end
这篇关于流浪者端口转发在Mavericks上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!