将设备连接到Mac localhost服务器? [英] Connect Device to Mac localhost Server?

查看:277
本文介绍了将设备连接到Mac localhost服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何允许任何设备(例如iPhone)通过WLAN连接到Mac的本地主机服务器?

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

在我的Mac上,我正在运行 Hello WorldHTTP Node.js 服务器,提供Safari成功打开的页面,位于 http: //本地主机:1337 。并且,在终端输出中运行 ipconfig getifaddr en1 192.168.1.9

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.

但是,Safari,iPhone和iPhone Mac,当它试图打开 http://192.168.1.9:1337 时显示Safari无法连接到服务器。

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.

我认为这不应该涉及端口转发,因为我只想要HTTP服务器可以私下使用,而不是公开使用。

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

相关:

  • Accessing localhost from iPhone (in same network)
  • https://superuser.com/questions/308451/connect-to-localhost-from-another-computer
  • https://superuser.com/questions/400752/can-we-run-local-server-over-local-network-without-internet-access
  • https://serverfault.com/questions/254947/accessing-localhost-xampp-from-another-computer-over-lan-network-how-to

推荐答案

我遇到了同样的问题。我在Mac上关闭了我的WI-FI,然后再打开它,这解决了问题。单击设置>关闭WI-FI。

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.

我通过在iPhone上访问Safari并输入我的主机名或IP地址来测试它。例如:
http://< name> .local http://10.0.1.5

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

这篇关于将设备连接到Mac localhost服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆