A lightweight, high-performance native implementation of Cloudflare Tunnel (cloudflared) engineered specifically for Android. Expose local web applications, APIs, Termux environments, and home servers to the public internet using Cloudflare Zero Trust without requiring root permissions, dynamic DNS, or router port-forwarding.
Interactive step-by-step setup walkthrough and troubleshooting guide: roufsweb.github.io/cloudflared-android
Ready-to-install application packages are published under Releases:
| Package | Supported Architecture | Minimum Android Version | Direct Download |
|---|---|---|---|
| Cloudflared Android APK | ARM64-v8a | Android 5.0+ (Lollipop through Android 15) | Download Latest APK |
- Standard Non-Root Execution: Runs completely inside the standard unprivileged Android app sandbox. No superuser, Magisk, or custom ROMs required.
- Universal Token Parser: Automatically extracts and validates Base64 tokens from any command copied from the Cloudflare dashboard (Windows
.exe, Linuxsudo, Docker, or raw token) with one-tap clipboard paste. - Integrated Engine Updates: Checks upstream Cloudflare releases and applies binary updates and kernel patches with a single tap in the app.
- In-App Usage Instructions: Built-in collapsible guide detailing token creation, background battery whitelist steps, and public hostname routing.
- Kernel Stdin DNS Patching: Overcomes Android's absence of
/etc/resolv.confby routing the Go runtime pure-Go resolver via//proc/self/fd/0with built-in upstream resolvers (1.1.1.1, 8.8.8.8). - Direct Boot Compatibility: Utilizes
LOCKED_BOOT_COMPLETEDbroadcast receivers to resume tunnel connections automatically after a system reboot, even before first user unlock. - Foreground Service Persistence: Operates as an Android high-priority foreground service (
dataSynctype) with partial WakeLock management to withstand aggressive OEM task termination. - Firewall & CGNAT Bypass: Outbound encrypted connections over QUIC (port 7844) or HTTP/2 (port 443) bypass carrier-grade NAT and restrictive ISP firewalls.
The application features a built-in token parser (TunnelTokenParser). When configuring a tunnel in the Cloudflare Zero Trust Dashboard, users can copy the full installation command provided under any operating system tab and paste it directly into the application. The parser strips executable names, sudo wrappers, CLI flags, quotes, and whitespace, isolating only the valid token payload:
| Source Format | Example Input Copied from Dashboard | App Parsing Behavior |
|---|---|---|
| Windows Command | cloudflared.exe service install eyJhIjoi... |
Automatically strips cloudflared.exe service install and extracts token |
| Linux Command | sudo cloudflared service install eyJhIjoi... |
Automatically strips sudo cloudflared service install and extracts token |
| Docker Command | docker run cloudflare/cloudflared:latest tunnel --token eyJhIjoi... |
Automatically isolates --token parameter value and strips flags |
| PowerShell / Paths | .\cloudflared.exe service install "eyJhIjoi..." |
Cleans quotation marks, relative execution prefixes, and arguments |
| Raw Base64 Token | eyJhIjoiMzEyNDZl... |
Trims whitespace, line breaks, and extraneous characters |
| One-Tap Clipboard | (Tap the clipboard icon inside the input field) | Fetches system clipboard and auto-parses contents directly |
Cloudflare Zero Trust tunnel tokens are Base64-encoded JSON objects containing account metadata:
{
"a": "<account_id>",
"t": "<tunnel_id>",
"s": "<secret>"
}Upon paste or typing, the application instantly verifies the Base64 structure, parses the a and t keys, and displays a live validation badge with the detected Tunnel ID (Valid Token • Tunnel: <id>...) so you can be confident your token is valid before starting the connection.
Standard Go binaries fail on Android because Android's Bionic C library does not provide /etc/resolv.conf, causing DNS lookup failures. This wrapper solves that natively:
[Local Application / Termux] (e.g. localhost:8080)
|
v
[Cloudflared Native Engine (libcloudflared.so)]
|
+--> DNS Redirection: Stdin Pipe -> //proc/self/fd/0 (1.1.1.1, 8.8.8.8)
|
v (Outbound HTTPS / QUIC on Port 7844 / 443)
[Cloudflare Edge Global Anycast Network]
|
v
[Public Internet / Custom Domain] (e.g. https://service.yourdomain.com)
- The compiled
cloudflaredbinary is packaged as a native shared library (libcloudflared.so) within the APK. - The Android service spawns the binary and pipes a generated resolver configuration directly into stdin.
- The patched engine parses nameservers via
//proc/self/fd/0, establishing secure outbound connections to Cloudflare Edge.
- Open the Cloudflare Zero Trust Dashboard.
- Navigate to Networks > Tunnels > Add a tunnel.
- Select Cloudflared and name your tunnel.
- Under Install and run a connector, copy the command provided under any OS tab (Windows, Linux, or Docker), or copy just the token string:
cloudflared.exe service install eyJhIjoiMzEyNDZl... # or sudo cloudflared service install eyJhIjoiMzEyNDZl...
- Install and launch
cloudflared-android.apk. - Tap the Paste from Clipboard icon in the Tunnel Token field (or paste manually). The app extracts and validates the token automatically, displaying a green confirmation badge with your Tunnel ID.
- Tap Connect Tunnel.
- Grant notification permission and allow the battery optimization exemption when prompted.
In the Cloudflare dashboard under the tunnel's Public Hostnames tab, assign a domain to your Android service:
- Public Hostname:
mydevice.yourdomain.com - Service Type:
HTTP - URL:
localhost:8080(or your target local port)
Host lightweight APIs, web servers, or static pages directly from Termux:
# Start a local web server in Termux
python3 -m http.server 8080
# In Cloudflare Dashboard: Route public hostname to localhost:8080Convert a spare Android smartphone or tablet into an always-on, low-power server for:
- Home Assistant dashboards and automations
- Node-RED automation workflows
- PocketBase or SQLite micro-backends
- Webhook ingestion (Stripe, GitHub, Discord bots)
To ensure uninterrupted 24/7 tunnel execution across device manufacturers:
| Vendor | Configuration Path | Setting |
|---|---|---|
| Google Pixel / AOSP | Settings > Apps > Cloudflared > App battery usage | Unrestricted |
| Samsung (One UI) | Settings > Battery > Background usage limits | Add to Never sleeping apps |
| Xiaomi (HyperOS / MIUI) | App Info > Battery saver | No restrictions & enable Autostart |
| OnePlus / Oppo / Realme | App Info > Battery usage | Enable Allow background activity & Allow auto-launch |
For comprehensive guides, visit the online documentation at roufsweb.github.io/cloudflared-android.
- Android Studio (2023.2.1 Iguana or newer)
- Android SDK 34
- JDK 17
./gradlew assembleReleaseThe output package will be generated at:
app/build/outputs/apk/release/cloudflared-android.apk
![]() Abdur Rouf Creator & Maintainer |
Google Antigravity Architecture & Engineering |
Cloudflare, Cloudflare Tunnel, and Cloudflare Zero Trust are registered trademarks of Cloudflare, Inc. This project is an independent open-source client and is not affiliated with or endorsed by Cloudflare.

