I want to connect to my local Web Server (NodeJS server) which runs on my MacBook with my iPhone.
On my Mac I can access the server via http://localhost:3000/
.
Now all it should take is to replace localhost with my Mac's local IP address like this http://192.168.0.13:3000/
. However, on my iPhone I cannot access the server this way and even when I try to open http://192.168.0.13:3000/
on my Mac there is no connection being established.
This is definitely a problem with my Mac and not with my program because when I run the server on Windows and try to connect to it with the local IP address it works just fine.
Also trying this in another Wi-Fi Network does not help or changing the port does not change anything either.
I am using Mac OSX 10.11.5 and my firewall is turned off.
How can I solve this problem?
Routing Tables (netstat -r
)
(Deleted)
Best Answer
As far as I can tell the behavior is correct. A basic node web server uses dns.js to resolve any hostname – which itself uses the system's DNS resolution method.
A hostname "127.0.0.1" as well as "localhost" can't be resolved by OS X's mDNS responder (neither non-reverse nor reverse).
So either use your Mac's IP (i.e. 192.168.0.13) or its hostname (e.g. tims-macbook-pro) as hostname. To advertise the service in Bonjour you have to use dns-sd.
Or create several listening IPs like in this q&a.