7

i'm running xp as a virtual machine on windows7 so that i can check what websites look like in ie 6 & 7 that i am building locally, on the same machine.

internet explorer will not find any page hosted on the loalhost. "Internet Explorer cannot display the webpage." i can put an ip address to another server on my lan, and that works fine, but if it is on the same machine, it refuses.

there is no proxy.

i have turned DNS Client Service on and off lotsa times, no effect.

can anybody help?

EDIT: my virtual machine's hosts file had lines like: 127.0.0.1 mydomain.dev

changokun
  • 1,563
  • 3
  • 20
  • 27
  • 2
    So, your web server is the win-7 host ? That's not 'localhost' on your winxp virtual machine, on that winxp machine, localhost is your winxp machine. Are you sure your web server(on win-7) is listening on all ip addresses and not just 127.0.0.1 ? – nos Dec 31 '10 at 22:11
  • Can you post the contents of your host file and what path you have it at? – i_am_jorf Jan 01 '11 at 03:11
  • hosts example added in edit. thanks, you would have seen my dumb error. – changokun Jan 03 '11 at 16:50

6 Answers6

6

thank you, nos and Andrew, you both helped me realize that i wasn't treating the virtual machine as it's own machine. my host file had lines like

127.0.0.1 mydomain.dev

which is perfectly valid, but it points to the virtual machine (where there is no web server sw). this is my first time using virtual machines, and i was just so used to my hosts file using 127.0.0.1 for my dev sites. what i needed was to use the ip address of the windows7 machine (where apache is running) instead:

192.168.1.42 mydomain.dev

i'm sure one of you would have seen my error if i hadn't been so sure of my hosts file. thanks! i hope this helps someone else!

changokun
  • 1,563
  • 3
  • 20
  • 27
3

If you mean localhost as in your Windows 7 machine it sounds like you are not using Bridge networking. That means your virtual machine can get to the outside but cannot see your local 192.168.* subnet.

Do this within your windows 7 in a command prompt

ipconfig /all

And this in your Windows XP

ipconfig /all

You'll probably get something like this on your windows 7 machine

(NIC) 192.168.1.100

Virtual-Box 192.168.10.100

and something like this on your windows xp

(NIC) 192.168.10.101

I suspect that your virtual machine is on a different subnet than your main computers NIC.

All hope isn't lost you can

  • Change your VM network bindings to bridged mode

  • or use the ip address that is in the same subject on your windows 7 machine as your Windows xp and ensure your web server is bound to 0.0.0.0 (all interfaces).

If you are trying to access the web server running on your windows 7 machine as 192.168.1.100 from your windows xp, you'll just change it to 192.168.10.100. Keep in mind I made up all these ip addresses and you'll need to change it to your own.

Andrew T Finnell
  • 13,417
  • 3
  • 33
  • 49
3

try the link 1, I had a similar problem and I took the effort to document it, I have not found this solution after looking for a few minutes.

Basically you have the go to your LAN settings of your internet explorer browser and disable automatic configuration. Don't worry this setting affects other browser as well.

Miguel
  • 53
  • 1
  • 6
2

Windows XP has to be rebooted for host files settings to apply to Internet Explorer.

Alex K
  • 14,893
  • 4
  • 31
  • 32
2

I ran into the same problem sometime back.

In IE10 and IE11 protected mode is always on by default. Add the URL to the trusted sites at the security tab of Internet Explorer settings. Uncheck SSL check box if site is running on http protocol only.

Also with Windows 8.1, unchecking "Automatically detect settings" at the LAN settings (connection tab) will enable custom entries in the HOSTS file.

This should fix the issue.

Taran
  • 139
  • 5
0

a 'quick' way to add host to your hosts file with the host machine's IP address so you can visit http://host:<port>/<path> inside your vm:

  1. In the the VM open an administrator console (Win, "cmd", CTRL+SHIFT+ENTER)

  2. run "CMD /f:off" (which allows pasting tab characters)

  3. Paste the following into cmd

    reg query "HKEY_CURRENT_USER\Volatile Environment\1" /v CLIENTNAME | more +2 > %TEMP%\clientname.txt & set /P regclientname=<%TEMP%\clientname.txt & call set CLIENTNAME=%regclientname:~28% & call echo %CLIENTNAME% & call nslookup %CLIENTNAME% | more +4 > %TEMP%\addr.txt & SET /P ADDR=<%TEMP%\addr.txt & call set HOSTIP=%ADDR:~10% & call echo %HOSTIP% & set HF=C:\windows\System32\drivers\etc\hosts && echo.>>%HF% && echo.>>%HF% && call echo  %HOSTIP%   host >>%HF% && type %HF%
    

NB: the extra "call" prefixes are so it picks up the variables set previously. It has to get CLIENTNAME from the registry as that is only set as a variable in unelevated sessions.


Alternatively!

  1. Win
  2. http://%CLIENTNAME%/
Sam Hasler
  • 12,344
  • 10
  • 72
  • 106