1

I have a Vagrant VirtualBox (Scotchbox) on my Mac Mini (Yosemite) and a test server inside the box (LAMP) running a website on it. From the iOS Simular and regular browsers I can reach it well.

From my Android Virtual Device (emulator64-arm, Android 4.2.2, native browser) on the same OSX (Yosemite) host I only get unformatted text and links, no image. - see below. cannot inspect elements inside the virtual device so no help there. When I load the site using the host name site.dev as stored in etc/hosts on the host (OSX) I get nothing at all. Only by ip at least I can load a broken site.

That is with this Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end

I changed from a private to public network to see if I could load a whole site from my Virtual Device.This is the Vagrantfile after the small tweak:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "public_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end

When I ran vagrant reload with public_network instead of private_network I see

vagrant@127.0.0.1's password:password
==> default: Checking if box 'scotch/box' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) en1: Wi-Fi (AirPort)
2) en2: Thunderbolt 1
3) en0: Ethernet
4) bridge0
5) p2p0
6) awdl0
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1

I picked one being on a wireless network.. Not sure if that was the best choice .. But then I was told:

NFS requires a host-only network to be created.
Please add a host-only network to the machine (with either DHCP or a
static IP) for NFS to work.

Any ideas why I cannot just load the site on my Virtual Device from Android Studio using the initial Vagrantfile setup? Localhost loaded just fine on 10.0.2.2. How to fix this issue?

screenshot of virtual device android virtual device

rhand
  • 1,176
  • 4
  • 17
  • 45
  • Read here that I should be able to reach the VagrantBox as both virtual boxes are on the same host http://stackoverflow.com/questions/28401565/how-can-i-access-a-vagrant-guest-from-another-virtualbox-guest?rq=1 – rhand Jul 25 '15 at 11:21
  • Just tried Chrome 37 on another virtual device and I still get the same page without images or layout. Just text and links. – rhand Jul 25 '15 at 12:45
  • Just on Lolipop trying to use the host name I got a connection refused so it seems my AVD is not allowed access to the Vagrant Box based website after all.. – rhand Jul 25 '15 at 13:16
  • After VBox upgrade the Android Studio Virtual Device refuses to load `emulator: Failed to sync HAX vcpu context` . Seems to be it cannot run together with VBox anymore...? Perhaps I need another solution.. Like allowing others on the network to access the box and use a real Samsung Tab running Android.. – rhand Jul 25 '15 at 13:56
  • After running AVD with ARM the `emulator: Failed to sync vcpu reg emulator: Failed to sync HAX vcpu context` went away. Found an answer to that here: http://stackoverflow.com/questions/17024538/how-do-i-fix-failed-to-sync-vcpu-reg-error Now see if I can connect to the Vagrant box as is the issue in this question. – rhand Jul 26 '15 at 05:20
  • Read here Vagrant and NFS demands a private network http://docs.vagrantup.com/v2/synced-folders/nfs.html just now. With VM Ware Fusion that does not seem to be the case, but will require a license for VM Ware and the Vagrant plugin. – rhand Jul 26 '15 at 05:32
  • Seems port fowarding on a private network does not work either to access it from another network device or in my case from my AVD: http://serverfault.com/questions/545413/expose-virtual-machine-vagrant-to-local-wifi – rhand Jul 26 '15 at 06:30

0 Answers0