I’m running into a small problem at the end of the Getting Started guide for vagrant. I’m working on a CentOS basebox that has Apache2 running (provisioning via Puppet). I’ve set up port forwarding for web requests using the following line in Vagrantfile:
config.vm.forward_port "web", 80, 4567
But when I make requests to that port, they fail. The error reported by Safari is ‘Safari can’t open the page “http://localhost:4567/” because the server unexpectedly dropped the connection.’
I did a vagrant reload and saw “[default] — web: 80 => 4567 (adapter 1)” in the scroll, so where should I begin to troubleshoot this? Thanks.
I’ll make this an actual answer instead of just more comments.
First thing: try
curl 'http://localhost:80'from within the VM. If that doesn’t work, then it’s definitely not the port forwarding.Next: try
curl -v 'http://localhost:4567/'from your host machine. Curl might give you a better error message than Safari.I’d check that there are no firewalls set up restricting access to port 80. The default Vagrant VM (Ubuntu) doesn’t come with a firewall set up, but you said you’re using something else, so it might be worth it to check.
If that’s not it, try making something other than Apache listed on port 80. Python ships with a simple HTTP server you can use — go to the folder with
index.htmland runsudo python -m SimpleHTTPServer 80, then try hitting that with curl from both boxes. If that works, then it’s probably an Apache configuration issue. I don’t have enough experience with Apache to help if that’s the case (I use nginx).