CLI Companion

  • Hugging Face CLI
    • login
    • whoami
    • repo create
    • upload
    • download
    • lfs-enable-largefiles
    • scan-cache
    • delete-cache
  • Hapi CLI
    • new
    • start
    • build
    • test
    • plugin create
    • route add
  • Cloudflared
    • tunnel
    • tunnel run
    • tunnel list
    • tunnel delete
    • access
    • access tcp
    • update

    The `cloudflared tunnel delete` command is used to remove a Cloudflare Tunnel from your Cloudflare account. Deleting a tunnel means it will no longer be available for routing traffic, and any DNS records pointing to it will become inactive (though the DNS records themselves are not automatically deleted by this command). If the tunnel connector (the `cloudflared` process) is still running when you delete the tunnel, it will lose its connection to Cloudflare's edge and eventually stop. You should typically stop the `cloudflared` process before deleting the tunnel.

    Syntax

    bash
    cloudflared tunnel delete <TUNNEL_NAME_OR_UUID> [flags]

    Arguments

    * `<TUNNEL_NAME_OR_UUID>`: This is a required argument. You must specify either the name of the tunnel or its UUID (Universally Unique Identifier) that you wish to delete.

    Flags

    * `--force`, `-f`: (Optional) Forces the deletion of a tunnel even if it has active connections. Use with caution, as this can interrupt ongoing traffic without gracefully disconnecting clients. It's generally better to stop the `cloudflared` process first.

    * `--config <path_to_config_file>`: (Optional) Specifies an alternate configuration file for `cloudflared`. By default, `cloudflared` looks for `~/.cloudflared/config.yml`.

    Usage Examples

    #### 1. Delete a tunnel by name

    To delete a tunnel named `my-web-tunnel`:

    bash
    cloudflared tunnel delete my-web-tunnel

    This command will prompt you for confirmation before proceeding with the deletion. For example:

    Are you sure you want to delete tunnel my-web-tunnel? [y/N]: y
    SUCCESS tunnel my-web-tunnel deleted

    #### 2. Delete a tunnel by UUID

    If you know the UUID of the tunnel, you can use that instead of the name. For example, to delete a tunnel with UUID `a1b2c3d4-e5f6-7890-1234-567890abcdef`:

    bash
    cloudflared tunnel delete a1b2c3d4-e5f6-7890-1234-567890abcdef

    #### 3. Force delete a tunnel

    If the tunnel has active `cloudflared` instances connected to it and you want to delete it without stopping them gracefully, you can use the `--force` flag. **Use this with caution as it can cause abrupt disconnections.**

    bash
    cloudflared tunnel delete my-web-tunnel --force

    This will bypass the confirmation prompt and immediately attempt to delete the tunnel.

    SUCCESS tunnel my-web-tunnel deleted

    #### 4. Delete a tunnel using a specific configuration file

    If your `cloudflared` setup uses a configuration file not in the default location, you can specify it:

    bash
    cloudflared tunnel delete my-web-tunnel --config /etc/cloudflared/prod_config.yml

    Important Considerations

    * **Stop connectors first:** It is highly recommended to stop all `cloudflared` processes associated with the tunnel *before* deleting it. This ensures a clean shutdown and avoids potential errors or orphaned processes.

    * **DNS records:** Deleting a tunnel does **not** automatically remove any CNAME or AAAA DNS records that point to that tunnel. You will need to manually remove or update those records in your Cloudflare DNS settings if they are no longer needed, otherwise, they will point to a non-existent tunnel and traffic will fail.

    * **Confirmation:** By default, `cloudflared tunnel delete` prompts for confirmation unless the `--force` flag is used. This is a safety measure to prevent accidental deletion.

    * **Irreversible:** Deleting a tunnel is an irreversible action. Once deleted, it cannot be recovered.