Reputation: 143
I'm running Laravel Homestead on my Windows PC. I want to be able to connect to my local environment with a physical phone (Android or iPhone). I've done some research but nothing seems to be working.
I've added a public network to my Homestead.yaml like the documentation says to do:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
ssl: true
#authorize: ~/.ssh/id_rsa.pub
#keys:
# - ~/.ssh/id_rsa
folders:
- map: C:\Users\john\Documents\Github\project
to: /home/vagrant/project
- map: C:\Users\john\Documents\Github\project\phpmyadmin
to: /home/vagrant/project/phpmyadmin
sites:
- map: homestead.test
to: /home/vagrant/project/public
- map: phpmyadmin.test
to: /home/vagrant/project/phpmyadmin/public
networks:
- type: "public_network"
ip: "192.168.10.20"
databases:
- homestead
features:
- mysql: false
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: false
If I go to 192.168.10.20 on my computer's browser, it works fine, but it's not connecting on my mobile phone and I don't know why.
What am I doing wrong? What do I need to change?
Upvotes: 1
Views: 685
Reputation: 11296
vagrant up
Before trying to add networks
into Homestead.yaml
, the answer might be simpler than you think. Try this:
When you run vagrant up
, look at the initialization output.
Look for clues that perhaps you should use a different port when attempting to access the site on a local mobile device.
Like...
==> homestead: Fixed port collision for 80 => 8000. Now on port 2200.
... and/or...
==> homestead: Forwarding ports...
homestead: 80 (guest) => 2200 (host) (adapter 1)
Then to access the Laravel project on a local mobile device (ie same WIFI network), try:
http://yourPCipAddress:2200
e.g. http://192.168.0.109:2200
The above works for me; I'm able to load my Laravel site on my local mobile devices.
I didn't need to make any change to Homestead or my OS hosts file. I don't think I have any other special config elsewhere. This is a fresh install of everything on a new Ubuntu machine.
For reference, here's my Homestead.yaml and hosts files. FYI, my Homestead.yaml has an alias domain defined (mysite.local), but this domain only works on my PC because it's only defined in the PC hosts file.
Homestead.yaml:
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects/mywebsite/code
to: /home/vagrant/code
sites:
- map: mywebsite.local
to: /home/vagrant/code/public
databases:
- homestead
features:
- mariadb: false
- ohmyzsh: false
- webdriver: false
My hosts file:
127.0.0.1 localhost
192.168.10.10 mywebsite.local
Upvotes: 2