It seems as if by default a VirtualBox VM (Virtual Machine) will start with a network connection set to NAT. This makes it a little difficult to connect to server services running on the VM (such as SSH, Apache, etc). An easy solution is to use the Host Interface directly as described here.
If you have your VM running you will need to shutdown the VM.
sudo shutdown -h now
Right click the VM > select Settings > go to the Network section > Adapter 1 Tab > Change Attached to: > Host Interface
Start the VM
Use the following to find out the IP address of the VM (you are looking for eth0)
Your network configuration may be different, I have my router set as DHCP, so it dishes out IPs to connecting clients, because of this it is not guaranteed that the VM will always get the same IP so I recommend setting the VM to have a static IP.
sudo vim /etc/network/interfaces
You will need to add the following (see: /etc/network/interfaces Ubuntu Linux networking example):
iface eth0 inet static address 192.168.1.5 netmask 255.255.255.0 gateway 192.168.1.254
Now reboot to reset the eth0 interface
sudo shutdown -r now
You should now be able to access the VM through the IP address.
If you need to use NAT, see: How to Access via SSH a Virtualbox Guest machine.