Reputation: 15008
I'm using VM Virtual Box. When I run a server code in the VM and then I open the browser in the host machine and type "localhost", I don't get the page I get in the VM. Probably, localhost in the VM and in the host machine are different. Do you know how to make the localhost of the VM the same as the one of the host?
dev@dev-VirtualBox:~$ ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:03:1a:e0
inet6 addr: fe80::a00:27ff:fe03:1ae0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:10813 errors:0 dropped:0 overruns:0 frame:0 TX packets:3337 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11494848 (11.4 MB) TX bytes:793819 (793.8 KB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:2128 errors:0 dropped:0 overruns:0 frame:0 TX packets:2128 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:192087 (192.0 KB) TX bytes:192087 (192.0 KB)
Upvotes: 2
Views: 2182
Reputation: 15037
Localhost is a special ip address 127.0.0.1 and it is the ip address of that computer on which you have physical access. To access localhost of another computer you MUST use the ip address of that computer... Set your virtual machine network interface to bridged mode and under that choose your lan or wifi card for network adapter. This way your virtual machine will get an ip address from your local network and you will be able to easily connect to that machine. If you need more information or help. Send me a message with @lewis4u at the beginning
When you run this command
sudo nano /etc/network/interfaces
you must get exactly this:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
And open network settings in VirtualBox and under Advanced hit that refresh button a few times so you get new MAC address
And there is one more thing! Under Adapter type in VirtualBox you MUST have your host network adapter (LAN or WIFI) if you don't know how to find it ask me.
Upvotes: 0