cloudflare/cloudflared · error

there should only be 1 non-deleted virtual network named %s

Error message

there should only be 1 non-deleted virtual network named %s

What it means

getVnetId resolves a virtual network name to its UUID by listing virtual networks filtered by name. The API contract expects exactly one non-deleted virtual network per name; when the list returns anything other than exactly one entry, cloudflared cannot resolve the name and raises this error.

Source

Thrown at cmd/cloudflared/tunnel/vnets_subcommands.go:273

}

func getVnetId(sc *subcommandContext, input string) (uuid.UUID, error) {
	val, err := uuid.Parse(input)
	if err == nil {
		return val, nil
	}

	filter := cfapi.NewVnetFilter()
	filter.WithDeleted(false)
	filter.ByName(input)

	vnets, err := sc.listVirtualNetworks(filter)
	if err != nil {
		return uuid.Nil, err
	}

	if len(vnets) != 1 {
		return uuid.Nil, fmt.Errorf("there should only be 1 non-deleted virtual network named %s", input)
	}

	return vnets[0].ID, nil
}

func formatAndPrintVnetsList(vnets []*cfapi.VirtualNetwork) {
	const (
		minWidth = 0
		tabWidth = 8
		padding  = 1
		padChar  = ' '
		flags    = 0
	)

	writer := tabwriter.NewWriter(os.Stdout, minWidth, tabWidth, padding, padChar, flags)
	defer writer.Flush()

	_, _ = fmt.Fprintln(writer, "ID\tNAME\tIS DEFAULT\tCOMMENT\tCREATED\tDELETED\t")

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. List virtual networks with `cloudflared tunnel network list` and use the exact existing name (or its UUID).
  2. Delete or rename duplicates so each name is unique among non-deleted vnets.
  3. Create the vnet first with `cloudflared tunnel network add <name>` if none exists.

Example fix

// before
cloudflared tunnel route ip add 10.0.0.0/24 vnet-prod-typo
// after
cloudflared tunnel network list
cloudflared tunnel route ip add 10.0.0.0/24 vnet-prod
Defensive patterns

Strategy: validation

Validate before calling

out, _ := exec.Command("cloudflared", "tunnel", "network", "list").Output()
if !strings.Contains(string(out), vnetName) {
    return fmt.Errorf("virtual network %q does not exist", vnetName)
}

Prevention

When it happens

Trigger: Running route/vnet subcommands (`cloudflared tunnel route ip add/delete`, `cloudflared tunnel network add/delete/update` path via getVnetId callers) with a vnet name that matches zero non-deleted virtual networks or is duplicated.

Common situations: Typo in the virtual network name; vnet was deleted; duplicate vnet names created in the account; operating against an account different from where the vnet lives.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/a5a04df5564ecbf1. Report an issue: GitHub.