How to Install & Setup Cloudflared in Termux (Safe Port Forwarding for Developers)
Author: Amal Aji | Updated: April 2026
⚠️ Disclaimer: This tutorial is for educational and legitimate development purposes only. Port forwarding should only be used to expose your own local servers for testing, learning, or hosting personal projects. Never use these techniques to gain unauthorized access to systems or to distribute malicious content. Unauthorized hacking is illegal and violates Google's policies.
If you’re a developer, you’ve probably faced this problem: you build a web app on your laptop, but you want to show it to a client or test it on your phone – without deploying to a public server. That’s where Cloudflared comes in. It creates a secure tunnel from your local machine to the internet, giving you a public URL instantly. In this guide, I’ll show you how to install and use Cloudflared on Termux (Android terminal emulator) for safe, legal port forwarding.
What Is Cloudflared and Why Use It?
Cloudflared is the command-line client for Cloudflare’s tunneling service. It securely exposes your localhost (e.g., a web server running on port 8080) to the internet without needing to configure your router. Unlike ngrok, Cloudflared offers generous free usage and better security.
Legitimate use cases:
- Share a local development website with remote team members.
- Test webhooks locally (e.g., for payment gateways or GitHub).
- Run a personal web server on your Android device using Termux.
- Learn networking and tunneling concepts safely.
Cloudflared is not a hacking tool – it’s a legitimate utility used by millions of developers worldwide. However, like any tool, it can be misused. Always follow the law and Cloudflare’s terms of service.
For more on ethical technology use, read our guide on what is ethical hacking.
Prerequisites: Install Termux on Android
Termux is a powerful terminal emulator for Android. First, install it from F-Droid (recommended) or the Google Play Store (older version).
Step-by-Step Installation of Cloudflared in Termux
Step 1: Update Termux Packages
pkg update && pkg upgrade -y
Step 2: Install Required Tools (wget and git)
pkg install wget git -y
Step 3: Download the Correct Cloudflared Binary
Open your browser and go to the official Cloudflared releases page. Find the file named cloudflared-linux-arm or cloudflared-linux-arm64 (depending on your device’s architecture – most modern Android phones use arm64). Copy the link address.
Step 4: Download the File Using wget
Back in Termux, type:
wget <COPIED_URL>
Replace <COPIED_URL> with the link you copied. For example:
wget https://github.com/cloudflare/cloudflared/releases/download/2025.3.0/cloudflared-linux-arm64
Step 5: Make the File Executable
chmod +x cloudflared-linux-arm64
How to Use Cloudflared to Expose a Local Server
First, make sure you have a local web server running on your device. For example, you could start a simple Python HTTP server on port 8000:
python3 -m http.server 8000
Then, open another Termux session (swipe from left edge and tap “New session”) and run:
./cloudflared-linux-arm64 tunnel --url http://localhost:8000
Or the shorter form:
./cloudflared-linux-arm64 http 8000
Cloudflared will generate a public URL like https://random-name.trycloudflare.com. Share this link – anyone can access your local server securely.
Important: The tunnel stays active as long as the command runs. Close it with Ctrl+C.
Real-World Example: Testing a WhatsApp Bot or Webhook
Suppose you’re building a WhatsApp bot using a framework like Baileys. You need a public URL for Meta’s webhook verification. Instead of deploying to a cloud server, you can run your bot locally on Termux, expose port 3000 with Cloudflared, and paste the generated URL into Meta’s developer dashboard. This is a common, legitimate use case.
If you’re interested in building useful apps with Python, check out our Python programming guide.
Troubleshooting Common Issues
- “Permission denied” – Run
chmod +x cloudflared-linux-arm64again. - “Exec format error” – You downloaded the wrong architecture. Try
cloudflared-linux-arm(32-bit) instead. - Connection timeout – Ensure your internet is working. Cloudflared requires an active connection.
- Port already in use – Change to a different port, e.g.,
8080.
Security and Legal Best Practices
- Never expose sensitive services (e.g., databases, SSH without keys) to the public internet.
- Use authentication layers (like HTTP basic auth) if your app handles user data.
- Do not use Cloudflared to bypass network restrictions or to conduct any illegal activity.
- Respect Cloudflare’s terms of service – free tunnels are for development, not production.
For more on staying safe online, read how to detect phishing links and signs your phone has been hacked.
Frequently Asked Questions (FAQ)
1. Is Cloudflared free to use?
Yes, Cloudflare’s tunneling service is free for development and personal use. There are no usage limits for the free tier, but it’s intended for testing – not high-traffic production sites. For production, Cloudflare offers paid Argo Tunnels.
2. Can I use Cloudflared on iOS or Windows?
Yes. Cloudflared works on Windows, macOS, Linux, and even iOS (via iSH shell). This Termux guide is for Android users. For Windows, download the .exe from the releases page.
3. Is port forwarding through Cloudflared safe?
Yes, it’s safer than traditional port forwarding because Cloudflared creates an encrypted tunnel (HTTPS) and does not require opening ports on your router. Your local machine is never directly exposed to the internet – only the tunnel endpoint is public.
4. What’s the difference between Cloudflared and ngrok?
Both do similar things, but Cloudflared is completely free with no time limits on sessions (ngrok free tier limits to 1 hour and slower speeds). Cloudflared also integrates with Cloudflare’s broader security features. For most developers, Cloudflared is the better choice.
5. Can I use a custom domain with Cloudflared?
Yes. If you own a domain and have it on Cloudflare’s DNS, you can create a subdomain (e.g., dev.yourdomain.com) and route traffic through the tunnel. That requires a Cloudflare account and setting up a tunnel with a configuration file. The basic method shown here uses the free trycloudflare.com subdomain.
Conclusion: Empower Your Development Workflow
Cloudflared is an essential tool for developers who work on mobile or want to share local projects without complex deployment. When used ethically, it saves time and opens up new possibilities – from testing APIs to hosting temporary demos. Follow the steps above, and you’ll have a public URL in minutes.
Remember: great power comes with responsibility. Always use tunneling tools legally and respect others’ privacy. Happy coding!
Related Posts You Might Like
- What is Ethical Hacking? A Complete Beginner’s Guide
- Python Programming from Beginner to Advanced
- How to Detect Phishing Links in WhatsApp – Stay Safe Online
- Signs Your Phone Has Been Hacked – What to Do Next
- Termux Commands – A Handy Reference for Beginners
Tags: Termux, Cloudflared, Port Forwarding, Localhost Tunnel, Developer Tools, Cloudflare, Android Development, Domebytes