Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - access local host from browser without internet connection

Tags:

android

I've installed local web server on my android tablet. But when all connections are off, every time I access the local site from built in browser (or Chrome), I get annoying popup message about "no internet connection" or something about sim card... is there any way to avoid that?

like image 555
Flash Thunder Avatar asked Jan 29 '14 10:01

Flash Thunder


People also ask

Can you connect to localhost without Internet?

The name resolution for the localhost need not have to be done over the internet. Localhost can also use the host file to block certain websites. For this, the website to be blocked must be entered into the list and the IP address 127.0.

How do I access localhost externally?

You are accesing localhost , meaning you have a web server running on your machine. To access it from Internet, you need to assign a public IP address to your machine. Then you can access http://<public_ip>:<port>/ . Port number is normally 80.

Does HTTP work without Internet?

Whereas, a HTTP server is used to serve Internet pages across the Internet. The point is, no HTTP or FTP server can serve users without an Internet access. However, it “may” depend on personal preferences. For example, some Servers are configured to handle users' requests via LAN, Local Area Network.


2 Answers

Most Browsers will check for an Internet connection when they start. What you can do (depending on how you are planning to use it):

  • Use WebView or Chromium Webview to create your own "browser"
  • Modify an existing browser: android default browser or lightning

If you choose for an existing browser to modify, I would recommend lightning because (as a quick look at the strings.xml file would suggest) It does not check for an internet connection.

like image 157
Mdlc Avatar answered Oct 17 '22 03:10

Mdlc


Problem may be caused by HTTP Proxy server. Proxies help to manage web traffic on the providers end, but can and probably will disrupt access to local addresses. Proxy options may be available in your network settings, but on many phones these options are hidden. An app such as HTTP Proxy Settings will give access to the hidden settings. Simply clear out the hostname and port for un-proxied access. Make sure to write down original values so changes can be undone.

If your device is configured to use a web proxy, then it'll never connect directly to localhost: it connects to the web proxy and asks that for the web page you really want. This won't work with a local web server.

To use a local web server, turn off your web proxy settings.

Original Answer
Original Answer #2

like image 32
hermann Avatar answered Oct 17 '22 01:10

hermann