I am trying to get a Vagrant/Laravel setup going, but there is only one problem: when I run php artisan serve
on my Vagrant VM, and try to view the project on my host machine browser, the browser says it can't connect/page isn't found.
Here is my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise32"
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.network "private_network", ip: "192.168.50.4"
config.vm.provider :virtualbox do |vb|
vb.name = "dev_host"
end
end
After I vagrant up
, I cd into my Laravel project folder and run php artisan serve
and it runs on localhost:8000, so I go to 192.168.50.4:8000 and it does not show up.
Any comments are appreciated!
You have to bind the PHP server to the specified IP (192.168.50.4), or to all interfaces (0.0.0.0). Even the port forwarding uses the implicit NAT interface instead of the loopback (localhost, 127.0.0.1) on the VM.
I was facing same problem
I made changes in vagrantfile
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "forwarded_port", guest: 8000, host: 8000
and ran following command to start laravel
php artisan serve --port=8000 --host=192.168.33.10
It works for me
Happy coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With