{"id":9750,"library":"flask-cloudflared","title":"Flask-Cloudflared","description":"Flask-Cloudflared (current version 0.0.15) is a Python library designed to effortlessly start a TryCloudflare Tunnel directly from your Flask application. It simplifies exposing your local development server to the internet via Cloudflare Tunnels, making it ideal for webhook testing, demos, or sharing progress without complex port forwarding. The library is actively maintained, with new patch versions released as needed.","status":"active","version":"0.0.15","language":"en","source_language":"en","source_url":"https://github.com/UWUplus/flask-cloudflared","tags":["flask","cloudflared","tunnel","development","networking"],"install":[{"cmd":"pip install flask-cloudflared","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core web framework integration.","package":"Flask","optional":false},{"reason":"Manages the Cloudflare Tunnel executable, providing a wrapper for its functionality.","package":"cloudflared","optional":false}],"imports":[{"symbol":"run_cloudflared_tunnel","correct":"from flask_cloudflared import run_cloudflared_tunnel"}],"quickstart":{"code":"import os\nfrom flask import Flask\nfrom flask_cloudflared import run_cloudflared_tunnel\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello_world():\n    return 'Hello, World!'\n\nif __name__ == '__main__':\n    # Cloudflared will attempt to expose the specified port (default Flask port is 5000)\n    # The tunnel runs in a separate process, allowing app.run() to proceed.\n    tunnel_url = run_cloudflared_tunnel(port=5000)\n    if tunnel_url:\n        print(f\"Cloudflare Tunnel is active at: {tunnel_url}\")\n    else:\n        print(\"Failed to start Cloudflare Tunnel.\")\n    \n    # Run the Flask application on the same port\n    app.run(port=5000)\n","lang":"python","description":"This quickstart demonstrates how to initialize a basic Flask application and start a Cloudflare Tunnel to expose it. The `run_cloudflared_tunnel` function handles the tunnel creation and outputs the public URL. Ensure Flask is running on the port specified for the tunnel."},"warnings":[{"fix":"Ensure the `cloudflared` Python package is installed (`pip install cloudflared`) and that the executable it provides is either in your system's PATH or directly callable. You can test by running `cloudflared --version` in your terminal.","message":"The `cloudflared` executable must be present and accessible in your system's PATH. Although `pip install cloudflared` helps, it doesn't always guarantee immediate accessibility in all environments, especially if relying on system-wide PATH configurations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Call `run_cloudflared_tunnel()` before `app.run()`, and ensure both use the identical port number. The `port` argument in `run_cloudflared_tunnel` should match the port Flask is listening on.","message":"The `run_cloudflared_tunnel` function is non-blocking, meaning it starts the tunnel in a separate subprocess. Ensure your Flask app starts *after* calling `run_cloudflared_tunnel` (as shown in quickstart) and on the same port, otherwise the tunnel might try to connect to a non-existent or wrong service.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin your dependency to an exact version (`flask-cloudflared==0.0.15`) in production. Regularly review the GitHub repository for release notes or breaking changes when upgrading.","message":"As a 0.0.x version library, `flask-cloudflared`'s API is subject to change without strict adherence to semantic versioning. While stable for its current features, expect potential minor breaking changes in future `0.0.y` releases.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the `cloudflared` Python package (`pip install cloudflared`) which typically handles the executable download. If it persists, manually install `cloudflared` from Cloudflare's official downloads and ensure it's in your system's PATH.","cause":"The `cloudflared` executable could not be found by the system. This often means it's not installed or not in the system's PATH.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'cloudflared'"},{"fix":"Change the port for your Flask application and the `run_cloudflared_tunnel` function to an available port, for example: `app.run(port=5001)` and `run_cloudflared_tunnel(port=5001)`.","cause":"Your Flask application is trying to start on a port (e.g., 5000) that is already being used by another process on your machine.","error":"OSError: [Errno 98] Address already in use"},{"fix":"Check the console output for any `cloudflared` specific errors. Ensure your local firewall isn't blocking outgoing connections. Verify your internet connection. Try running `cloudflared tunnel --help` in your terminal to confirm the executable works independently.","cause":"General connection issues, firewall blocking, incorrect `cloudflared` configuration, or problems with Cloudflare's network.","error":"Cloudflared tunnel failed to start or connect."}]}