Reputation: 65510
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?
Upvotes: 5
Views: 10805
Reputation: 81
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
Upvotes: 8
Reputation: 13920
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
Upvotes: 4