Cloudflare Tunnel Setup
Access your Mac from anywhere using a free Cloudflare Tunnel.
Cloudflare Tunnel lets you connect to your Mac from any network -- cellular data, a different WiFi, or across the world. No port forwarding or router changes needed.
When to use this
- Your iPhone is on a different network than your Mac (e.g. you're on the go).
- Your network blocks direct device-to-device connections.
- You want HTTPS/WSS encryption by default.
How it works
cloudflared creates an outbound-only tunnel from your Mac to Cloudflare's edge. Your iPhone connects to a Cloudflare URL, and traffic is relayed to your Mac. No ports are opened on your router.
Option A: Quick tunnel (temporary)
This is the fastest way to get started. No Cloudflare account required. The URL is random and changes each time you restart.
Using the Mac app
Toggle Cloudflare Tunnel in the Mac app's settings. The app runs cloudflared internally and displays the tunnel URL.
Using the command line
Install cloudflared:
Start a quick tunnel:
cloudflared outputs a URL like https://random-words.trycloudflare.com. Use this URL in the iPhone app (set connection mode to Public / Cloudflare).
Option B: Named tunnel (persistent URL)
For daily use, a named tunnel gives you a stable URL that doesn't change.
Requirements:
- A free Cloudflare account.
- A domain managed by Cloudflare (can be a free domain).
Steps:
-
Authenticate:
-
Create a tunnel:
-
Configure DNS: point a subdomain to your tunnel:
-
Create a config file at
~/.cloudflared/config.yml: -
Run:
Your persistent URL is now wss://remote.yourdomain.com.
Connect from iPhone
- In the iPhone app, switch to Public (Cloudflare) connection mode.
- Enter the tunnel URL (either the random
*.trycloudflare.comor your named domain). - Enter the API key (required for public access).
- Tap Connect.
Important: Always set an API key for public tunnels
When your server is reachable from the internet, an API key is mandatory. Set it as an environment variable before starting the server:
Or let the Mac app generate one for you (shown in the menu bar panel).
Troubleshooting
- Tunnel connects but iPhone can't reach it: make sure the local server is running on the same port the tunnel points to (default:
8765). - DNS not resolving: for named tunnels, check that the CNAME record exists in your Cloudflare dashboard.
- Random URL changed: quick tunnels generate a new URL each restart. Use a named tunnel for persistence.