我正在做一个移动网站,想用我的iPhone浏览器测试一下。我的Windows 7电脑和iPhone都在同一个无线网络上。如何从iPhone访问localhost ?现在我得到一个404错误。


当前回答

试试这个:

按Windows + R 打开cmd 执行命令ipconfig(旧)ifconfig(新) 检查你的无线网卡IP 打开iPhone,导航到“http://xxx.xxx.xxx”。Xxx /"通过浏览器。 (xxx.xxx.xxx。xxx是你的IP)

注意:你必须在你的防火墙设置上设置权限,如果有的话。

其他回答

如果你使用的是mac,请确保编辑/etc/hosts文件。 根据上面的说明找到IP地址,并将以下行添加到该文件中

172.x.xx.x.x outer

在那之后,上面的步骤起作用了:在我的iphone浏览器中导航到正确的页面,访问http://172.x.xx.x.x:port http://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want

找到你系统的IP地址和你运行网站的端口。

假设您的IP地址是121.300.00.250,端口是8080。

[端口号:在运行页面时看到您的web浏览器,例如:localhost:8080/…]那么端口号是8080]

现在在你的手机转到121.300.00.250:8080/..你会找到你的网站。

重要提示:您必须确保您的服务器(例如Apache Tomcat)处于启动状态

你可以试试ngrok.io。工作原理与localtunnel相同。 下载适合您的操作系统的应用程序。试着这样跑:

linux:

./ngrok http 8000

8000是应用程序正在运行的端口号。

windows:

 ngrok.exe http 8000

For Mac users, open up the Network Utility (You can find this by typing cmd + space which will open spotlight and then in spotlight start typing Network Utility). Select Network Utility, when it's open, your IP address will be found next to the label IP Address. So basically with the IP, you can get into any open ports on your local mac e.g. if your website is running locally on localhost:3000 and your ip address is 154.31.92.0 then from your phone you can get the website simply by typing 154.31.92.0:3000 into a browser.

PS-这只适用于手机和电脑在同一个网络上

对于那些使用正确IP地址但仍然无法连接到本地服务器的人,另一件要检查的事情是您或您的同事没有将设备配置为使用代理服务器。

我有一台设备无法连接,结果发现该设备被配置为使用Charles Proxy,当然它没有运行。