flower_green
flower_green

Reputation: 1404

Cannot access site from host machine on a vagrant virtual machine

I setup a nginx+mysql puphpet/vagrant image, with a virtual host "test.com". I mapped test.com to 192.168.56.101 on the host machine, and put an index.php file inside /var/www/test.

However, when I try opening the browser at the address test.com on the host machine I get no response. I feel like I'm missing something really simple, because I can ping 192.168.56.101. I also checked nginx logs on the virtual machine, but they are empty. Any clues where the problem might be? Am I not supposed to use it this way? I can ssh into vagrant just fine, and also I can access the mysql db.

Upvotes: 0

Views: 4862

Answers (1)

Robin
Robin

Reputation: 1190

In your Vagrantfile, you need to forward the port to your host machine.

For example map port 80 of the Vagrant machine to port 8080 of the host machine.

config.vm.network "forwarded_port", guest: 80, host: 8080

Upvotes: 1

Related Questions