2

I want to access VirtualBox's localhost using a smartphone for me to see how the website looks like in a phone.

More Details:

  • Host OS - Windows 7 Pro
  • Guest OS - Ubuntu 16.0.4 LTS
  • SmartPhones' OS - Android and iOS
  • You can configure port forwarding on Virtualbox, and then connect to the IP of your Windows 7 machine using your smartphone (via a wifi connection or similar). – user2064000 Apr 18 '17 at 8:01
  • do you know or do you have a tutorial of how I can do it? – Dumb Question Apr 18 '17 at 8:03
3

You actually shouldn't need this, most browsers have a "responsive design view mode" which you can activate by pressing F12 to activate the developer console and clicking on the mobile phone/tablet icon on the left of it.

But to answer your question, yes, this can be done through port forwarding.

  • Go to the settings for the Ubuntu VM, and select the "Network" tab.
  • Make sure that the "Attached to" value is "NAT".
  • Click on the "Advanced" dropdown and click on the "Port Forwarding" button.
  • Click on the "+" symbol to add a port forwarding rule. Say, you have a server running in Ubuntu in port 80, so enter 80 in the "Guest Port" value. Now, say, you want to access the server on port 8080 of the host machine, so type in 8080 for the "Host Port" value.
  • Click on "OK" on the windows to save your settings.

At this point, you can access your server on your host machine by typing in localhost:8080.

To open it on your phone, connect the phone and the computer on the same network (such as a WiFi hotspot). Determine the local IP address of your computer with ipconfig /all. For example, if the IP is 192.168.1.1, type in 192.168.1.1:8080 on your phone.

  • Hi, do you know how I can access the phpmyadmin in the host machine? It gives me forbidden error. Thanks! – Dumb Question Jun 27 '17 at 1:46
  • Really useful, just don't forget to (disable the guest firewall or) add a rule on the guest firewall to allow incoming traffic from the host OS or any other device connected to the WiFi. – Jesús Hagiwara May 30 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.