I think I solved the problem with a bit more digging on the internet. I tried running Mathematica from a terminal and this eventually gave messages similar to this one:
LinkConnect::linkc: -- Message text not found -- (LinkObject[ctq_shm, 1, 1])
These were files in the /tmp/MathLink folder and the message was different each time I tried to run the command Mathematica -clean. The solution was to add a couple of lines of code to the /etc/network/interfaces file, reboot the Pi and Macbook and then it worked okay.
The two lines of code were:
iface lo inet loopback
I have no idea what it does but it worked... If someone want's to explain what it means I would be happy to know!