2

I've been trying to change the mapping for a domain and forward it to a Vagrant machine that I've forwarded a port to.

The config in Vagrantfile:

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

I've updated /etc/hosts on my Mac OSX with the following:

127.0.0.1:4567 example.com

Yet when I access from my browser example.com nothing changes, I have also tried to map example.com to go to the Google IP without any luck.

What am I overlooking?

Lorena Nicole
  • 499
  • 2
  • 9
  • 21

1 Answers1

3

I would just add a static ip, or try removing the port number:

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "192.168.50.4"
end

Then in your hosts file change it to read:

192.168.50.4 example.com

More info is available here: https://docs.vagrantup.com/v2/networking/private_network.html

Brian Barthold
  • 1,593
  • 4
  • 22
  • 39
  • Works like a charm - still curious about the way I was setting up my etc/hosts. When I ssh into the vagrant box and run ifconfig I see in the 'inet' an IP address -- I used that too without luck. Seems like I'm missing the correct IP address to use when I forward a port. – Lorena Nicole Jul 11 '14 at 15:04