7

On my work Mac (Sierra) I'm running a NodeJS webserver on localhost, port 3000. I need to access to it from Internet Explorer running in Parallels for testing purposes.

I have searched and read and experimented extensively, and have thus far been stymied. My current situation is as follows:

I've got a Parallels "Host-Only" network with my Mac at 10.37.129.2 and my virtual Windows box at 10.37.129.3

Pointing my IE to 10.37.129.2:3000 fails.

I've jumped through every hoop imaginable to ensure port 3000 is open between the two, but nmap -p 3000 10.37.129.2 from the Windows side tells me port 3000 remains closed, as does Mac's Network Utility Port Scan software.

Sadly all guides and advice on the subject are either insufficiently similar, grossly outdated, or simply unsuccessful when attempted.

Any progress you help me achieve is greatly appreciated.


The relevant portions of my server.js are:

const port = process.env.PORT || 3000;
const host = process.env.HOST || 'localhost';
const proxyTarget = process.env.PROXY || 'none';
  • Did you try my proposals? – klanomath Nov 21 '16 at 13:20
  • Yes, you absolutely set me straight and put me on the right path. @klanomath – Michael Plotke Nov 21 '16 at 13:30
3

The "technical background" of the special behavior (at least on Macs) of using localhost as "host constant" is the specific nature of dns.js, which obviously binds the node http/https server to the interface it reverse-resolves to the const host (= localhost) with the help of mDNSResponder.

This is localhost > 127.0.0.1 > lo0.

Any other interface like en0/en1 as physical interfaces or vnic0/vnic1 as Parallels' virtual interfaces won't be addressed/attached.

To solve this you may either

  • set up a DNS-server like dnsmasq in Parallels' Host-only network and use the fqdn of the node http server host as host const
  • use the IP-address of the node http server in Parallels' Host-only network as host const
  • modify the hosts files of every host in Parallels' Host-only network and add a line like 10.37.129.2 testserver.example.com and use testserver.example.com as host const
  • Hi, thanks for the answer, but is there any better explanation? I have no idea how to achieve any of the three. "host const" does not return anything, but link to this post. – tomitrescak Mar 5 '18 at 4:50
  • Ok, got it, this helped: toddvachon.com/2013/04/… – tomitrescak Mar 5 '18 at 4:55
10

One of the way I could use it, I found my local IP4 address provided by the router.

From Mac system preferences > Network > IP Address: 192.168.x.xx

And let say if you access it in Mac with http://localhost:3000 you can do it also with http://192.168.x.xx:3000 from Mac itself and from Parallel Windows OS with shared network configuration.

This IP address could be changed each time you restart the router or choose another router etc.

Currently, I'm using Parallels Desktop 12

  • I think this is the simplest solution – bhoo-day Jun 14 at 1:57
1

The temporary solution is to edit server.js and set host = '10.37.129.2' or set the HOST system variable to 10.37.129.2 and read it in with host = process.env.HOST || 'localhost'. It may also be possible to edit /private/etc/hosts to map 10.37.129.2 to localhost, though my quick test of that failed.

Everything was behaving precisely as expected. The localhost name is mapped to 127.0.0.1, and not to any network facing IP address. Thus 10.37.129.2, which was my Mac's IP on the virtual network shared with Windows running in Parallels, was never reaching localhost. This is correct and reasonable.

All credit goes to klanomath. Thanks!

  • 2
    localhost is a "magical" name and you can't/mustn't set it to anything else than a 127.x.y.z IP-address. You would have to set it also in any client's hosts file to be able to reach the remote "localhost|10.37.129.2" which would break any related RFC standard and render the clients' hosts files useless in respect to their own "localhost'iness". (I don't know how to say it precisely in English...) – klanomath Nov 21 '16 at 13:44
0

Just run in the terminal:

ifconfig

And go to vnic0: inet address from the Parallels (like http://1x.2xx.5x.2:3000/ for ex.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .