Skip to content

Instantly share code, notes, and snippets.

@jmwhittaker
Created March 14, 2011 15:22
Show Gist options
  • Save jmwhittaker/869300 to your computer and use it in GitHub Desktop.
Save jmwhittaker/869300 to your computer and use it in GitHub Desktop.
Get localhost working in VMWare
Connect to your Mac's localhost from within a VMWare virtual machine.
- Boot up VMware and fire up your VM (i'm using Windows 7)
- Make sure that the VM is using NAT
- Fire up the command prompt in Windows and type "ipconfig". IN the resulting text look for your IPv4 address. It will be something like 192.168.xxx.xxx
- Now go to your browser in your VM and type that ip address into the url bar but change the last set of digits to be 2 (or 1).
- so as an example if your ip was found to be 192.168.213.200 change it to be 192.168.213.2
- Assuming that your localhost is running on your mac you should get your localhost in your VM browser.
- If you need to add a non standard port number on the end like 8090 go ahead and do so.
Adding to a hosts file
- Make a new entry in the hosts file that maps to this address. You can't add custom port numbers in a Windows hosts file.
@nicholasdunbar
Copy link

Thank you for your contribution. It helped me a bunch. I wrote a more in depth article to help others who come upon your instructions and may need more information at http://boulderapps.co/make-your-xampp-site-on-your-mac-accessible-to-windows-on-vmware

@aaronsmulktis
Copy link

Worked like a charm, thanks

@user24
Copy link

user24 commented Apr 30, 2014

Very helpful, thankyou.

@Vadorequest
Copy link

Works fine, didn't know that. I'm trying to do the reverse now. ^^

@levani
Copy link

levani commented Aug 25, 2014

I get "403 Forbidden" error on my windows 7 virtual machine... any ideas?

@matt-bailey
Copy link

This worked for me, but I had to also add a second network adapter set to 'Host-only'.

For what it's worth, my set-up is as follows:

  • Mac OS X Yosemite 10.10.1
  • Default OS X Apache and PHP
  • VirtualHostX for creating the virtual hosts on my Mac

@outoflimit666
Copy link

Who would have thought it could be that easy. Working great, thanks

@Kwon11
Copy link

Kwon11 commented Apr 18, 2019

You the man

@MaximePie
Copy link

I'm curious, is there a particular reason for changing the found ip from 192.168.213.200 to 192.168.213.2 ?

@Kwon11
Copy link

Kwon11 commented Jul 16, 2019

One of my ports (9000) works, but 1234 and 34212 does not. Any advice?

Woah. Only one of my dev servers works on port 9000. If I try to switch what was on 1234 over to 9000, it doesn't work. That seems like some sort of project config not a VMware thing. Will share when I get to the bottom of this

Answer Edit: webpack dev server needs to be run with flag --host 0.0.0.0 if you want it to accept requests from outside your local machine (in your local network).

@MIsabelZM
Copy link

Worked perfectly! ✨

@mhulse
Copy link

mhulse commented Jan 18, 2021

Thanks to @Kwon11, I finally figured out how to connect to my macOS Hugo server from Windows IE Edge tester box.

On my mac, when firing up the Hugo server:

hugo serve --port=1337 --bind=0.0.0.0

Then, on my macOS, get IP from System Preferences > Network and use that in Edge to connect:

http://192.168.0.16:1337/

My VMWare Fusion is setup to use NAT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment