Cannot browse site hosted on local machine from a

2019-02-25 06:38发布

问题:

I generated empty backbone application from backbone-generator on my OS X 10.9.1. Then changed the connect hostname in Gruntfile.js to '0.0.0.0' and start the app.

The issue is that I cannot access the application from Android connected to the same home wifi network. I know that my local machine ip is 192.168.1.101. So, I typed in a mobile browser 192.168.1.101:9000 but nothing is loaded.

I have found several similar questions on SO:

  • How to browse localhost on android device?
  • Android cannot access localhost?

But the answers did not help me and I cannot comment on them because of my low reputation.

Could anybody help with this issue and say what I'm missing?

回答1:

It turned out that the issue reason was in the router wifi settings. The "WDS Settings" was disabled and to let devices communicate over network it should be enabled.



回答2:

Questions that you reported deal with a local http server running on Android, in your case the application is running on your local machine, so it is necessary that your local machine and Android phone have IP addresses in the same subnet.

If you need to assign an IP_ADDRESS to your local machine (wi-fi interface), you can run in the Terminal

sudo ipconfig set en1 INFORM IP_ADDRESS

it may be useful for development purpose.