Connect Device to Mac localhost Server?

106

How do I allow any device, e.g., iPhone, to connect over a WLAN to my Mac's localhost server?

On my Mac, I'm running a "Hello World" HTTP Node.js server that serves a page, which Safari opens successfully, at http://localhost:1337. And, running ipconfig getifaddr en1 in Terminal outputs 192.168.1.9.

But, Safari, on both iPhone & Mac, displays "Safari can't connect to the server" when it tries to open http://192.168.1.9:1337.

I don't think this should involve port forwarding because I only want the HTTP server to be available privately, not publicly.

Related:

This question is tagged with iphone localhost lan wifi localserver

~ Asked on 2012-09-30 00:24:42

The Best Answer is


47

Have your server listen on 0.0.0.0 instead of localhost.

~ Answered on 2012-09-30 00:25:16


58

I had the same problem. I turned off my WI-FI on my Mac and then turned it on again, which solved the problem. Click Settings > Turn WI-FI Off.

I tested it by going to Safari on my iPhone and entering my host name or IP address. For example: http://<name>.local or http://10.0.1.5

~ Answered on 2014-09-26 18:14:40


Most Viewed Questions: