简体   繁体   English

流浪汉港口转发不适用于小牛队

[英]Vagrant port forwarding not working on Mavericks

I'm using a vagrant Geodjango box and port forwarding is not working for me. 我正在使用一个流浪的Geodjango盒子 ,端口转发对我不起作用。

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. 但是http://localhost:8000http://localhost:4567都没有在主机上找到任何内容。

On the Vagrant box, curl -v 'http://localhost:8000/' gives the usual: 在Vagrant框中, curl -v 'http://localhost:8000/'给出了通常的:

<h2>Congratulations on your first Django-powered page.</h2>

which suggests that Django is running okay. 这表明Django运行正常。 But on the host machine, trying curl -v 'http://localhost:8000/' gives the following output: 但是在主机上,尝试curl -v 'http://localhost:8000/'会得到以下输出:

curl: (7) Failed connect to localhost:8000; Connection refused

My Vagrantfile has the following port forwarding set up: 我的Vagrantfile具有以下端口转发设置:

config.vm.forward_port 8000, 4567

Disabling the Mac's firewall does not help and stopping Apache makes no difference. 禁用Mac的防火墙没有帮助,停止Apache没有任何区别。 I have tried running lsof -i :8000 on the host machine and there is no output, so I figure nothing is using the port. 我已经尝试在主机上运行lsof -i :8000并且没有输出,所以我认为什么都没有使用该端口。

Can anyone suggest anything? 谁能提出任何建议?

I had the same issue on Yosemite and none of the ports were forwarding. 我在优胜美地遇到了同样的问题,没有一个端口正在转发。 Disabling the Firewall filter on the guest machine helped: 禁用来宾计算机上的防火墙过滤器有助于:

sudo service iptables stop

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). 只想添加我的2美分,在V2 Vagrantfile中,端口转发代码块如下所示,尝试使用新的,以避免端口冲突(回到v1我总是困惑哪个是哪个)。

config.vm.forward_port 8000, 4567 is forwarding guest port 8000 to host 4567, not the other way around. config.vm.forward_port 8000, 4567将guest config.vm.forward_port 8000, 4567端口8000转发到主机4567,而不是相反。

In V2 format, it looks like below, which is clearer from my opinion 在V2格式中,它看起来像下面,从我的意见更清楚

Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM