Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Turn Your Own Machine Into a Public API Server (For Free) Using Cloudflare Tunnel

Description and use

Expose a local API to the internet without port forwarding using Cloudflare Tunnel.

Problem

Expose a local API to the internet without port forwarding, firewall changes, or cloud deployment.

Outcome

Local FastAPI server is securely exposed to the internet via Cloudflare Tunnel without opening inbound ports or changing firewall settings.

Workflow

  • Install cloudflared via brew
  • Log in with cloudflared tunnel login
  • Create a tunnel with cloudflared tunnel create my-tunnel
  • (Optional) Map a domain with cloudflared tunnel route dns my-tunnel api.yourwebsite.com
  • Create ~/.cloudflared/config.yml with tunnel ID, credentials file, and ingress rules
  • Run the tunnel with cloudflared tunnel run my-tunnel
  • (Optional) Use launchctl on macOS to keep the tunnel alive

Evidence

cloudflared connects out to Cloudflare, so your router and firewall stay closed.

Source

No domain? For quick tests, cloudflared tunnel --url http://localhost:8000 gives you a temporary trycloudflare.com address instead.

Source

  • Record date: 2026-10-25T04:11:09.967Z