39

When connected to the Internet, the system checks if it's in a walled garden, which is simply trying to connect to Google. If it fails, in Android 5, there'll be an exclamation mark on the WiFi icon or signal icon.

In some situations, this is annoying. Say, in China, Google is blocked, the exclamation mark will always be there, which is meaningless.

How can I disable this check, and make the system assume, connected WiFi/mobile data is connected Internet?

6

3 Answers 3

35

It's simple. In the terminal (requires root), or in adb shell (does not require root), issue the command

settings put global captive_portal_detection_enabled 0

and reboot. It should be disabled. The existing state can also be verified via the command

settings get global captive_portal_detection_enabled

A response of "null" indicates the global key value has not been set and Android will fall back to default of being on and performing the detection. If the detection is disabled the response of "0" will be received.

More info: Android : How to remove “captive portal” detection on android 4.2.2 and 4.3

It also works in 5.

6
  • Great! I note that the link describes doing this in 4.2.2 and 4.3. Have you (or anybody else) verified that this also works in 5.0.x?
    – Flyto
    Commented Feb 23, 2015 at 17:03
  • @SimonW yes, it works. That's why I tagged the question lollipop. I'm using CyanogenMod 12 though.
    – Qian
    Commented Feb 24, 2015 at 2:36
  • 1
    Comment by Gery, lacking the rep for it: For the ones who use terminal for the first time, don't forget to put the command "su" before you do anything, to allow superuser permissions. (It took a while for me to figure why am getting "permission denied") After that it worked like a charm.
    – Izzy
    Commented Jul 6, 2015 at 13:07
  • 1
    Starting from Nougat (I guess, might be 7.1.2 only, or already Marshmallow), use settings put global captive_portal_mode 0 instead, see jira.lineageos.org/browse/REGRESSION-620
    – bonob
    Commented Oct 20, 2017 at 11:40
  • In order to write this setting, you might (Android >= 8?) have to set SELinux to permissive first: su; setenforce 0; setting put .... Commented Feb 28, 2018 at 8:37
14

In the Android M Developer Preview for Shamu (Nexus 6), and possibly other builds of this OS, the captive_portal_server global is used by the OS regardless of the state of captive_portal_detection_enabled in order to determine health of a WiFi network.

For WiFi networks, it will not only draw an exclamation mark on the strength icon, it will blacklist that SSID from auto-reconnecting if it does not successfully curl the URL specified in the the captive_portal_server global via that SSID. Manual reconnection is allowed but will only remain connected if you have captive_portal_detection_enabled and choose "Use This Network As-Is" manually, each time you connect to that WiFi SSID. This override is temporary.

For mobile provider networks, the captive_portal_server is only used to draw an exclamation mark on the strength icon but will remain connected, and traffic will flow if the connection is functional.

On your rooted device, the solution is to re-enable captive_portal_detection_enabled if you have disabled it, connect to that WiFi network, select "Use This Network As-Is" from the drop down menu in the captive portal pop-up, disable your mobile network data to focus on determining a website that can be retrieved via your Wifi network by logging in to your captive portal and then use a browser to find one that works. After that, you can disable captive_portal_detection_enabled to prevent the annoying pop-up.

To reenable your captive_portal_detection, if you previously disabled it, issue the command:

settings put global captive_portal_detection_enabled 1

Disable your Mobile Network (under Settings - Data Usage - Mobile Data - Off), to force the phone to use the WiFi network for all traffic, temporarily. This will not be required once you have all of your settings where they need to be.

Android M seems to require a website that loads successfully and does not actively return a 204 (no content).

A couple of options include but are not limited to

androidcheck.kiritostudio.com
captive.apple.com
www.textise.net
the network router
localhost
127.0.0.1 (if you have an onboard simple HTTP server)
and the list goes on...

After finding one that works for your WiFi Network (often requires more imagination and attempts behind corporate web gateway proxies that do not like HTTPS traffic prior to authentication), you can save the server.

Save the server by running this in your root enabled terminal app, replacing the example URL with the one you are hoping will work:

settings put global captive_portal_server androidcheck.kiritostudio.com

Restart your device. Try it out. Once you are happy with the behavior of the Exclamation Marks on the icons, the final step is to disable the captive portal pop-up, which is one of the most unfortunate inventions of this decade.

Issue command:

settings put global captive_portal_detection_enabled 0

If you find yourself in a different country or WiFi situation where issues arise, unfortunately you will need to repeat the above from the beginning, reenabling captive_portal_detection_enabled, restarting, finding the right server and then disabling the portal detection afterwards.

2
  • Did you mean HTTP 204 (no content) or HTTP 404 (not found)? Currently I changed to "no content" based on another answer
    – Andrew T.
    Commented Sep 10, 2015 at 8:43
  • This solved the "connected, no internet" problem on Nougat. Running fresh-flashed CM14.1 (7.1.2) on Nexus.
    – Yvon
    Commented Sep 17, 2017 at 14:21
1

You can setup your captive portal server address to it.

settings put global captive_portal_server g.cn

Then, restart your phone.

PS: Before that, you can validate the server is available.

http://g.cn/generate_204

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .