← all posts

Solving the Parallels Networking Puzzle: Accessing Mac localhost from a Windows VM

Gordon Beeming
Gordon Beeming
On this page5 sections ▾

Running a Windows VM in Parallels is a regular part of my workflow for testing cross-platform compatibility. The idea is that everything running on the Mac should be reachable from the Windows guest too. Networking, though, has a way of making that harder than it sounds.

You spin up your .NET web app, it's running fine on localhost on your Mac, you open a browser in Windows to test it, and... Hmmm... can't reach this page. If you've been down this rabbit hole, keep reading. 😅

#The first hurdle: "It works on my machine"

The classic developer excuse, but this time it's literally true. The web app works fine on the Mac, but not the VM. First thing to check: what IP address is your application actually bound to?

The lsof command in the macOS terminal is useful here:

Terminal
lsof -nP -iTCP:<your_port_number> | grep LISTEN

My output showed the app was only listening on 127.0.0.1, the localhost loopback address. That means it only accepts connections from the Mac itself.

Terminal output from the lsof command showing a process listening on 127.0.0.1:port
The first clue: The app is only listening for local traffic.

The fix is to tell your application to listen on all available network interfaces by binding it to 0.0.0.0. For a .NET app, change this in launchSettings.json:

launchSettings.json
// "applicationUrl": "http://localhost:15072"
"applicationUrl": "http://0.0.0.0:15072"

After restarting, lsof confirmed the app was listening on *:<port>. Open to the local network. Problem solved, right?

#The plot twist: it still doesn't work

With the server correctly configured, I went back to the Windows VM and tried to connect. First I tried http://0.0.0.0:15072. That failed. Then my Mac's local network IP. That also failed.

So the server was definitely listening, but something between the VM and the Mac was dropping the connection. Firewall? VPN? I started checking both.

A browser inside the Windows VM failing to connect, showing an error page.
The server is listening, but the VM can't see it. The mystery deepens.

#The real culprit: hiding in plain sight

The firewall was fine. After some digging, I found the actual problem somewhere I hadn't thought to look: the Windows hosts file.

Parallels automatically adds entries to that file to help with host-guest communication. What I found there, though, was broken.

The Windows hosts file showing the hostname 'mac' pointing to 0.0.0.0
The smoking gun: Parallels incorrectly mapped 'mac' to a blackhole address.

The file had an entry mapping the hostname mac to 0.0.0.0. I assume Parallels put it there intentionally, but in this case it was sending any request to mac straight into a black hole, blocking all access to the Mac host.

#The solution

The fix was simple enough once I knew where to look. In Parallels' Shared Network mode, the Mac host is almost always reachable at 10.211.55.2.

  1. Open Notepad as an Administrator in Windows.
  2. Open the file C:\Windows\System32\drivers\etc\hosts.
  3. Find the incorrect line and fix it.

Before:

hosts (before)
0.0.0.0       mac

After:

hosts (after)
# Manual fix for connecting to the host mac
10.211.55.2   mac

After saving, I opened a browser in the Windows VM, hit http://mac:<port>, and it loaded first try.

It also fixed access to Docker containers running on the Mac. I could reach them at http://mac:<port>, and for SQL Server the connection string used mac,<port>.

#Cheers

Hope this saves you the time I lost tracking it down. If it helped, let me know on X (@GordonBeeming) or LinkedIn (gordon-beeming), or drop a comment below. 😅

Gordon Beeming
Gordon Beeming

Father • Husband • Triathlete • SSW Solution Architect

Related posts