Vagrant localhost issue

236 Views Asked by At

I installed Vagrant and VM on my Ubuntu 15, add a box and did a vagrant up with not a problem. But I cant connect to my project when I say to my browser 127.0.0.1:8080. What can I be doing wrong on vagrant?

This is my Vagrantfile:

Vagrant.configure(2) do |config|
  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://10.0.1.254:3128/"
    config.proxy.https    = "http://10.0.1.254:3128/"
    config.proxy.no_proxy = "localhost,127.0.0.1,.teste.com"
  end
  config.vm.box = "hashicorp/precise32"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end
1

There are 1 best solutions below

0
On

You might be able to sidestep this issue by using a private network instead of port forwarding. Comment out the "forwarded_port" line in your Vagrantfile and add the following instead:

config.vm.network "private_network", ip:"192.168.50.4"

This will work as long as you use an ip address that isn't being used on your network already. The one above should be fine.

This also allows you to access your site via a nice url by adding the following line to your /etc/hosts file on the machine that's hosting vagrant:

192.168.50.4    mysite.dev