I have a local test/development server (HTTP, of course), listening to port 8000.
I'm working on Linux, so to test the page on Internet Explorer 6, 7, 8, etc. I run a virtual machine using VirtualBox; I also need to see how it look on Firefox in a windows environment (fonts for instance are different).
In my real machine, I open the website simply using the URL http://localhost:8000
, how do I address this localhost from the virtual machine?
Right now my workaround is to use the IP address. Any better ideas?
I need to run on localhost, not some weird IP.
1) From your Mac terminal, do
iconfig -a
to find your local IP address. It's probably the last one.en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV> ether 38:c9:86:32:0e:69 inet6 fe80::ea:393e:a54f:635%en7 prefixlen 64 secured scopeid 0xe inet 10.1.5.60 netmask 0xfffffe00 broadcast 10.1.5.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect (1000baseT <full-duplex,flow-control>) status: active
e.g. 10.1.5.60
2) boot up your windows image. start > type
cmd
to get a terminal3)
notepad c:\windows\system32\drivers\etc\hosts
4) add the following line
10.1.5.60 localhost
5) open IE, and the following url should hit the server running on your mac:
http://localhost:3000/
In Virtual Box
Now the tricky bit is your localhost, if you are running from Node.js set the IP address to 0.0.0.0, then lookup your own IP address, for example cmd:ipconfig --> 10.0.1.3
Type that address in with the port number. And it will work.
I found that
10.0.2.2:<port>
works, but only if Promiscuous Mode is set correctly. After installing my VM, I went to Settings > Network > Adapter 1.NAT is set by default, and the Promiscuous Mode dropdown is disabled. I switched from NAT to Bridged Adapter, which enabled the Promiscuous Mode dropdown, and then changed the value from "Deny" to "Allow VMs". I then switched back to NAT, which disabled Promiscuous Mode again, but retained the new value.
After only this change, I was able to launch my VM and see my host machines
localhost:<port>
on my VM at10.0.2.2:<port>
.You need to edit your hosts file on your Windows Virtual machine the same way you do for your local host machine:
C:\WINDOWS\system32\drivers\etc\hosts
And link your virtual hosts to 10.0.2.2, If you are just using localhost then replace
127.0.0.1 localhost with 10.0.2.2 localhost
For example:
This tells your virtual machine to point to your local machine for those domain names.
You don't need to change hosts file or any Virtual Box configuration. Keep settings in NAT. Go to your Windows instance and run "cmd" or open cmd.exe. Execute command "ipconfig" and get the Default Gateway IP Address. Browse http://10.0.2.2:8080 on Windows IE you will see is the same than your Mac Safari http://localhost:8080/ or http://127.0.0.1:8080
check if you can hit your parent machine with:
ipconfig
(get your ip address)ping <ip>
ortelnet <ip> <port>
If you cannot get to the port, try adding a new inbound rule in your parent firewall allowing local ports.
I was then able to access
http://<ip>:<port>