Captive Portal parameters


There are several captive portal parameters one could apply to an Android device via settings put global – the most famous probably being

settings put global captive_portal_detection_enabled 0

to completely turn off captive portal check (for Android < 8). Can someone explain how to use the others – e.g. to define a "custom captive portal server for tin-foils"? For example, one cannot simply do a

settings put global captive_portal_server

as that would, in most cases, cause captive portal check to permanently fail (background: doing so, portal check would construct an URL and check against that, expecting a specific response).

So apart from simply deactivating captive portal check altogether (which might, as I've read, lead to other issues like not being redirected to the correct portal in some cases), what else can one do to enhance privacy in this context?

Examples (if I got them right):

  • captive_portal_mode (Android 8+?):

    • 0: Don't attempt to detect captive portals

    • 1: Prompt the user to sign in

    • 2: Immediately disconnect from the network and do not reconnect to that network in the future

  • captive_portal_detection_enabled (Android <8?):

    • 0: Completely disable captive portal checks

    • 1: Enable it (default)

While these examples are pretty much straight-forward: How to use the other parameters?


Configuring captive portal behaviour

  • captive_portal_detection_enabled (<= Android 7.1.1)

    • works as described in question body

  • captive_portal_mode (>= Android 7.1.2)

    • works as described in question body

Setting captive portal URL(s)

  • captive_portal_server (<= Android 6.0.1)

    • The server that holds a generate_204 page, used to internally craft a URL for captive portal detection (new URL("http", mServer, "/generate_204"); – obsolete as of Android 7.0, see below)

  • captive_portal_use_https (>= Android 7.0)

    • 0: Don't use HTTPS for network validation

    • 1: Use HTTPS (default)

  • captive_portal_http_url (>= Android 7.0)

    • The URL used for HTTP captive portal detection - use in pair with captive_portal_use_https (set to 0)

    • >= Android 7.1.1: OS no longer appends generate_204 to URL automatically, giving input URL some flexibility

  • captive_portal_https_url (>= Android 7.0)

    • The URL used for HTTPS captive portal detection - use in pair with captive_portal_use_https (set to 1)

    • >= Android 7.1.1: OS no longer appends generate_204 to URL automatically

Requirement for the URL to be used

A HTTP 204 response code ("no content") from the server is used for validation, no extra content needed: take the default detection URL for example, curl returns empty, and inspecting HTTP response by adding --write-out %{ http_code } returns 204.'

A small list of usable captive portal server URLs in mainland China (personally tested) (hosted by (hosted by Xiaomi, used by default on MIUI) (hosted by & (hosted by Google) (hosted by Qualcomm)

Further notes

The source also mentions parameters captive_portal_user_agent, captive_portal_fallback_url and captive_portal_other_fallback_urls:

  • captive_portal_fallback_url (>= Android 7.1.1) obviously is supposed to hold a single URL, while

  • captive_portal_other_fallback_urls holds multiple further URLs (comma separated list, so the URLs might not contain any comma).

But I personally conducted tests on Android 8.0.0, and both fallback parameters don't work. Assuming they're declarations without an implementation for now.

Some examples of captive portal settings of Android in China show the use of some of the above settings:

adb shell settings put global captive_portal_http_url
adb shell settings put global captive_portal_https_url
adb shell settings put global captive_portal_fallback_url
adb shell settings put global captive_portal_other_fallback_urls

Knowing that, "tin foils" even could set up their own verification service. With Apache:

RewriteEngine On
RewriteCond %{ REQUEST_URI } /generate_204$
RewriteRule $ / [R=204,L]

or with Nginx:

location / generate_204 {
 return 204 ; 


1, 2 (Chinese), 3 (Chinese)


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes