how to access a windows 10 localhost address in an oracle virtual box running windows 7

6,058

Localhost is restricted to the machine only.

So a localhost on the host, is only accessible through the host itself.

http://localhost or http://127.0.0.1 will use the loopback device of the network card to redirect traffic back to itself.

If you try this inside the guest, it will obviously redirect the traffic back to itself too.

So in order to access the website from the guest to the host, it must be accessible on the LAN ip address, such as 192.168.1.53 (example ip address) or the hostname (PCname)

You also need to ensure that the guest can access this ip address from within the VM. This can be done by setting the network interface as bridged which will place the guest inside your LAN making it equal. Otherwise you need to open the correct ports and ensure that the ip addresses are setup correctly.

Share:
6,058

Related videos on Youtube

Joshua
Author by

Joshua

Full stack web developer, recent graduate from Post University

Updated on September 18, 2022

Comments

  • Joshua
    Joshua over 1 year

    Thus far I have attempted to change host ip addresses, connected through nat and host-only, and by ip adress. is there a way to open a localhost connection by ip from windows 7 guest to windows 10 host using virtual box. Currently, the only browser I need to test is IE 11. Any help with configuration suggestions would be greatly appreciated.

    update:

    to clarify, I wish to access the website itself for testing purposes within the virtual machine. I want to run the local development version of the site, in the virtual machine, without having to publish

    • Admin
      Admin over 7 years
      Your question is not clear. "Localhost" is the local computer, so "localhost" in the VM is the VM itself (Windows 7), and "localhost" on the VM Host is host itself (Windows 10).
    • Admin
      Admin over 7 years
      localhost refers to the machine itself. Unless the vm and the host os have the same hostname, you can't connect to the vm from the host os, by using localhost. Even if the hostname is the same, it doesn't make sense, to connect to localhost since it can refer to both the guest os and the host os. In other words what your attempting to do doesn't make sense, localhost only goes to 127.0.0.1 by default
    • Admin
      Admin over 7 years
      point of clarification. I wish to access the website itself for testing purposes within the virtual machine. To clarify, I want to run the local development version of the site, in the virtual machine, without having to publish
    • Admin
      Admin over 7 years
      "I wish to access the website itself for testing purposes within the virtual machine. " - So connect to the ip address or hostname of the server, you will NOT be able to use localhost, unless you are on the server itself. The VM in this case is a seperate machine and not considered to be the server
    • Admin
      Admin over 7 years
      @Ramhound is there a means by which I can do that? resolve the hostname to be the same in both locations?
    • Admin
      Admin over 7 years
      @Ramhound I believe that may be the issue. Since localhost treats itself as a server, and the virtual machine is on the same computer as the localhost,
    • Admin
      Admin over 7 years
      @Joshua - No; Just define a different hostname. Your Host OS should have a different ip address then your Guest OS for obvious reasons. You don't want the server and the client attempting to connect to the server to be the samething, you prove nothing by doing that, you can connect to localhost on the server if you want to do to that (and thus elminate the VM all together).
    • Admin
      Admin over 7 years
      @Ramhound. Thank you for the clarification. I will try that presently
  • Joshua
    Joshua over 7 years
    to clarify, is the guest the virtual machine, or the terminal itself
  • LPChip
    LPChip over 7 years
    the guest is the virtual machine.