Vagrantfile:
config.vm.network "forwarded_port", guest: 8080, host: 8080
On my virtual machine I am running this command:
python manage.py runserver 0.0.0.0:8080
But when I try to curl
on host machine, response is curl: (52) Empty reply from server
and on browser it says 127.0.0.1 didn’t send any data.
I looked on stackoverflow for this problem, most of them were able to resolve it by adding 0.0.0.0
to the runserver
command. But, I have already added it.
I tried:
Disabling the firewall
and allowing all connections to the virtual machine by accepting all input and output in iptables.
I changed the 127.0.0.1 localhost
in /etc/hosts to 0.0.0.0 localhost
but still the same response.
I ensured that my host machine is not preventing it by disabling the firewall on my host machine too.
Note: I am using ubuntu machine on virtual box and mac OS on host.
While the virtual machine is running, any changes to the Vagrantfile are not properly registered by the machine even if you run vagrant up
.
To ensure that all the changes get reflected correctly, the virtual machine should be halted and then run again.
In my case, I had changed the forwarding ports while the vagrant was running. I was doing vagrant up
assuming the changes will get reflected but they did not.
Doing vagrant halt
followed by vagrant up
solved my issue.