简体   繁体   English

从移动设备测试应用程序时出错 - ERR_CONNECTION_REFUSED

[英]Error when testing app from mobile device - ERR_CONNECTION_REFUSED

After upgrading to OSX Yosemite, I can no longer test my app on a mobile device by using my development machine's (MacBook Pro) IP address. 升级到OSX Yosemite后,我无法再使用我的开发机器(MacBook Pro)IP地址在移动设备上测试我的应用程序。 For example, I used to be able to view a Rails app on a phone by going to http://192.168.0.4:3000 , but now I get the following error: 例如,我曾经能够通过访问http://192.168.0.4:3000在手机上查看Rails应用程序,但现在我收到以下错误:

ERR_CONNECTION_REFUSED

I get the same error when testing an AngularJS app using the grunt server running at http://192.168.0.4:9000 使用运行在http://192.168.0.4:9000的grunt服务器测试AngularJS应用程序时出现同样的错误

Any help will be greatly appreciated. 任何帮助将不胜感激。

It could help to bind the server to your local IP, like 它可以帮助将服务器绑定到您的本地IP,例如

rails s -p9000 -b192.168.0.4

to start your rails app 启动你的rails应用程序

Consider giving a try to Pow . 考虑尝试Pow Its pretty simple to install, and a great solution to share a local development across multiple devices. 它非常易于安装,是跨多个设备共享本地开发的绝佳解决方案。

Like it explains in their homepage, you can install it with just : curl get.pow.cx | sh 就像它在主页上解释的那样,你只需要安装它: curl get.pow.cx | sh curl get.pow.cx | sh . curl get.pow.cx | sh To prevent any errors, install in Terminal app outside a Tmux session. 要防止出现任何错误,请在Tmux会话外部的终端应用程序中安装。

And just symlink your app : 只需对您的应用进行符号链接:

 cd ~/.pow
 ln -s /path/to/myapp

You can access your app at http://myapp.dev/ , and at http://myapp.[your ip address].xip.io from another device. 您可以访问http://myapp.dev/上的应用程序,以及来自其他设备的http://myapp.[your ip address].xip.io

Not a direct response to your issue, but an alternative to setting yourself a configuration in your preferences. 不是对您的问题的直接回复,而是在您的偏好设置中设置自己的配置的替代方案。

Turn IPv6 off . 关闭IPv6 It Prevented me from connecting to my localhost from other computers on my LAN. 它阻止我从LAN上的其他计算机连接到我的localhost。 And, with the newer versions of OSX there is no way to turn it off in the Network Preferences Panel so you have to do it from terminal. 而且,使用较新版本的OSX,无法在网络首选项面板中将其关闭,因此您必须从终端进行此操作。

Open Terminal and enter to turn it off: 打开终端并输入以将其关闭:

networksetup -setv6off Wi-Fi

And this to turn it back on: 这将把它重新打开:

networksetup -setv6LinkLocal Wi-Fi

If you are connected via Ethernet or something else just run this command to list the available options: 如果您通过以太网或其他方式连接,只需运行此命令列出可用选项:

networksetup -listallnetworkservices

and replace "Wi-Fi" with the appropriate device. 并用适当的设备替换“Wi-Fi”。

我没有mac,但这似乎是服务器不接受连接,如果是这种情况,它只接受localhost连接,尝试绑定de server接受所有连接或绑定到0.0.0.0 ip

Can you access that IP from Browser? 你能从浏览器访问那个IP吗? are you sure your IP is in the same range with 192.168.0.4? 你确定你的IP与192.168.0.4在同一范围内吗? It is your mobile device connected on the same network? 您的移动设备是否连接在同一网络上? Maybe you used internet sharing before update to Yosemite and now is off? 也许你在更新到Yosemite之前使用了互联网共享,现在已经关闭了?

I think your IP address changed. 我认为您的IP地址已更改。 Telnet from console(terminal) your IP port. 从控制台(终端)Telnet您的IP端口。 If 192.168.0.4 is your real Ip then maybe add(as root or via sudo) an entry in /etc/host file an entry as 127.0.0.1 192.168.0.4. 如果192.168.0.4是你真正的IP,那么可以在/ etc / host文件中添加(作为root或sudo)条目127.0.0.1 192.168.0.4。 Restart network or reboot. 重启网络或重启。 Also you can try nmap ( on ip to see open ports). 您也可以尝试使用nmap(在ip上查看开放端口)。 Nmap has been ported to OSX just google for installer. Nmap已经移植到OSX只是谷歌安装程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AJAX返回net :: ERR_CONNECTION_REFUSED - AJAX returns net::ERR_CONNECTION_REFUSED Docker容器的ERR_CONNECTION_REFUSED - ERR_CONNECTION_REFUSED by docker container 与'ws:// localhost:35729 / livereload'的WebSocket连接失败:连接建立错误:net :: ERR_CONNECTION_REFUSED - WebSocket connection to 'ws://localhost:35729/livereload' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED 无法在开发模式下在Rails应用上加载资产:ERR_CONNECTION_REFUSED - Cannot load assets in dev mode on rails app : ERR_CONNECTION_REFUSED Chrome 可以很好地连接到以“rails s”开头的 Rails 服务器,在系统规范期间因 ERR_CONNECTION_REFUSED 失败 - Chrome connects fine to Rails server started with `rails s`, fails with ERR_CONNECTION_REFUSED during system specs 耙db:seed错误'耙中止了! 错误编号:: ECONNREFUSED:连接被拒绝' - rake db:seed error 'rake aborted! Err no::ECONNREFUSED: Connection refused ' Rails应用程序错误连接被拒绝-Nginx和PUMA - Rails app error connection refused - nginx & puma React 上的连接被拒绝错误 - Connection Refused Error on React Capybara、Rails、Selenium、Chromedriver + ERR:CONNECTION_REFUSED - Capybara, Rails, Selenium, Chromedriver + ERR:CONNECTION_REFUSED Elasticsearch 连接时连接被拒绝 - Elasticsearch Connection refused when connect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM