Want to know how to access your MAMP environment from within a virtual instance of Windows or Linux (like VirtualBox or VMware fusion or Parallels)? Read on!
You already have a local development environment set up using MAMP (MAMP uses port 8888 so your localhost is accessed at http://localhost:8888 and custom sites, assuming you have set any up, are available at http://whatever:8888).
Sadly you need to test your sites in Internet Explorer (or more interestingly you want to run in Linux and use cool tools like cachegrind) so you have set up a virtual environment to do this. I am using Sun’s Oracle’s fantastic, open source application VirtualBox. The question is, how do you access your local sites from within VirtualBox? Launching IE or your Linux browser and going to http://localhost:8888 does not work… hmmm.
Turns out, the address you need to point at is http://10.0.0.2:8888. That will get you to MAMP’s htdocs directory, i.e. your http://localhost:8888!
Now that is useful but it doesn’t get give you access to your custom sites. Here is how you access those!
- Open your hosts file. In Windows it is found here:
C:\windows\system32\drivers\etc\hostsand in Linux it is found here:/etc/hosts - Under the bit that says:
127.0.0.1 localhostadd the following (using whatever your actual project is called):10.0.2.2 whatever
That’s it! Now you can visit http://whatever:8888 using IE or any other browser from within your virtual Windows and/or Linux environments.
Example hosts file (all I added was the third line):
127.0.0.1 localhost
127.0.0.1 ubuntu-vm
10.0.2.2 mynewsapp
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
etc, etc...
And now in my virtual environment’s browser I can access:
http://mynewsapp:8888/
(which is hosted in my Mac’s MAMP instance! Sweet!)






#1 by Stefano on March 12, 2010 - 9:50 am
Thank you so much!
[Vertaal]
#2 by jeremy clarke on April 16, 2010 - 6:39 pm
Fuck yeah! Thanks for the tip man. Exactly what I was looking for. I actually got everything but forgot my stupid :8888!
I tried some other searches before I found this one, so I’ll keyword jam the comment for the sake of others: This works great when using Virtualbox with OSX Mac Hosts files Windows XP.
[Vertaal]
#3 by Craig on November 8, 2010 - 9:12 am
You can setup DNS on your Mac, and get the virtual machines to use it, and BIND allows a wild-card setup, so no need to keep adding entries for every website on every virtual machine:
http://www.craigfrancis.co.uk/features/setup/bind/
[Vertaal]
#4 by Fran on November 29, 2010 - 1:16 pm
Awesome. I just setup my virtual Windows 7 for testing websites against Internet Explorer using VirtualBox on OSX. I also use MAMP and this tip really helped me to run my MAMP localhost in VirtualBox and Windows 7.
Thanks!
[Vertaal]
#5 by Shalaco on December 30, 2010 - 1:33 am
Awesome tip!
Worked amazing.
I use 80 for my port Apache port so I don’t have to deal with that 8888 nonsense. And I changed 10.0.2.2 to localhost in the host file so that I can use the same naming convention on my computer and VM.
However, when I installed IETester IE5.5 through IE7 hated it.
Had to use http://10.0.2.2/directory/
Any thoughts?
[Vertaal]
#6 by Blaise Kal on February 24, 2011 - 6:51 am
Thanks for this! This also worked with my Django install.
[Vertaal]
#7 by Jason on September 5, 2011 - 7:02 pm
There’s an error in your text:
“Turns out, the address you need to point at is http://10.0.0.2:8888.”
No, its 10.0.2.2:8888
[Vertaal]
#8 by Ian on December 20, 2011 - 12:58 pm
Hi
I have virtualbox on MAMP Mac os x host with windows 7 guest, and it does not load http://10.0.2.2:8888
What network adapter setup do I need, and am I missing something obvious?
many thanks
Ian
[Vertaal]
#9 by Travis on January 10, 2012 - 10:53 pm
Thanks so much for the post. Definitely saved me hours of banging my head against the wall. (y)
[Vertaal]