Can't get website running in virtual machine to display in browser, networking confusion
This is a question about networking in Ubuntu I suppose, but requires some background.
I am a Linux novice. I have a Trellis Wordpress site I've taken over, so set up a dual-boot laptop with Ubuntu 18.04 (version required by the setup/environment). I followed the previous developer's instructions to setup the environment, clone the project, then enter the trellis folder and do a vagrant up.
This all works, I get this:
==> default: Machine 'default' has a post vagrant up message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default:
==> default: Your Trellis Vagrant box is ready to use!
==> default: * Composer and WP-CLI commands need to be run on the virtual machine
==> default: for any post-provision modifications.
==> default: * You can SSH into the machine with vagrant ssh.
==> default: * Then navigate to your WordPress sites at /srv/www
==> default: or to your Trellis files at /home/vagrant/trellis.
ubuntu@ubuntu-laptop:~/uweek-cms/trellis$
I should then (by the notes) be able to use a local browser to navigate to the website: http://uweekdev.abaso.co.uk/
But that doesn't work, Chrome (and Firefox) report:
This site can’t be reached
uweekdev.abaso.co.uk refused to connect.
So Trellis has inserted a line in the hosts file: cat /etc/hosts reads:
## vagrant-hostmanager-start id: 16ff5846-31d4-4402-aa91-479139d39183
192.168.50.5 uweekdev.abaso.co.uk
## vagrant-hostmanager-end
The previous developer talked about about network adaptors during installation of Ubuntu itself, but in the context of it being installed virtually, but as the docs were written for both ubuntu as an OS, and using VirtualBox on Windows, so I'm not sure if I've missed a step!
Here's ifconfig's output on the HOST machine:
## vagrant-hostmanager-start id: 16ff5846-31d4-4402-aa91-479139d39183
192.168.50.5 uweekdev.abaso.co.uk
## vagrant-hostmanager-end
ubuntu@ubuntu-laptop:~/uweek-cms/trellis$ ifconfig
enp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 54:e1:ad:8e:30:09 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4190 bytes 612036 (612.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4190 bytes 612036 (612.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.1 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 fe80::800:27ff:fe00:0 prefixlen 64 scopeid 0x20<link>
ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 78 bytes 9312 (9.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::ebb5:652:1251:6b01 prefixlen 64 scopeid 0x20<link>
ether 44:03:2c:4b:d6:88 txqueuelen 1000 (Ethernet)
RX packets 3300 bytes 2803503 (2.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2431 bytes 462691 (462.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ubuntu@ubuntu-laptop:~/uweek-cms/trellis$ ifconfig -s -a
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
enp1s0 1500 0 0 0 0 0 0 0 0 BMU
lo 65536 4204 0 0 0 4204 0 0 0 LRU
vboxnet0 1500 0 0 0 0 90 0 0 0 BMRU
wlp2s0 1500 3526 0 0 0 2712 0 0 0 BMRU
And here it is when I vagrant ssh into the client virtual machine:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fed2:10a5 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:d2:10:a5 txqueuelen 1000 (Ethernet)
RX packets 2844 bytes 315692 (315.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2184 bytes 341128 (341.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.5 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 fe80::a00:27ff:fe34:19a5 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:34:19:a5 txqueuelen 1000 (Ethernet)
RX packets 96 bytes 7852 (7.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 113 bytes 8864 (8.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 22 bytes 1824 (1.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 1824 (1.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Now I confess I'm lost. I don't understand any of the networking side of this and I'm not sure how to progress to get the website running in the virtual machine to load in my browser!
Any ideas what to do to troubleshoot/try/check?
Many thanks for helping out an enthusiastic novice.
You will want to edit your /etc/hosts
file, as the IP address does not match the one reported by your virtual machine.
In /etc/hosts
, change:
192.168.50.5 uweekdev.abaso.co.uk
to:
192.168.50.1 uweekdev.abaso.co.uk
Save the file and, if needs be, clear your browser cache to force it to look up the domain again. This should resolve your issue 👍🏻
One item to look at is whether VirtualBox is configured to allow network traffic in to the VM or not. You can find this in the "Network Settings" bit of the VM configuration:
You will want to confirm that the "Promiscuous Mode" is set to "Allow All", otherwise VirtualBox will block traffic to the VM.