cloudflare/cloudflared · error

You must supply at least 2 arguments, first the network you

Error message

You must supply at least 2 arguments, first the network you wish to route (in CIDR form e.g. 1.2.3.4/32) and then the tunnel ID to proxy with

What it means

cloudflared's `tunnel route ip add` command requires exactly the CIDR network and the tunnel ID/name as positional arguments. This error is returned by addRouteCommand when fewer than 2 positional arguments are provided, aborting before any API call is made.

Source

Thrown at cmd/cloudflared/tunnel/teamnet_subcommands.go:137

		return renderOutput(outputFormat, routes)
	}

	if len(routes) > 0 {
		formatAndPrintRouteList(routes)
	} else {
		fmt.Println("No routes were found for the given filter flags. You can use 'cloudflared tunnel route ip add' to add a route.")
	}

	return nil
}

func addRouteCommand(c *cli.Context) error {
	sc, err := newSubcommandContext(c)
	if err != nil {
		return err
	}
	if c.NArg() < 2 {
		return errors.New("You must supply at least 2 arguments, first the network you wish to route (in CIDR form e.g. 1.2.3.4/32) and then the tunnel ID to proxy with")
	}

	args := c.Args()

	_, network, err := net.ParseCIDR(args.Get(0))
	if err != nil {
		return errors.Wrap(err, "Invalid network CIDR")
	}
	if network == nil {
		return errors.New("Invalid network CIDR")
	}

	tunnelRef := args.Get(1)
	tunnelID, err := sc.findID(tunnelRef)
	if err != nil {
		return errors.Wrap(err, "Invalid tunnel")
	}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Supply both arguments: `cloudflared tunnel route ip add 10.0.0.0/8 <TUNNEL-UUID-OR-NAME>`
  2. List tunnels with `cloudflared tunnel list` to get the tunnel ID or name
  3. Check `cloudflared tunnel route ip add --help` for the expected argument order (network first, tunnel second)

Example fix

// before
$ cloudflared tunnel route ip add 10.0.0.0/8
// error: You must supply at least 2 arguments...
// after
$ cloudflared tunnel route ip add 10.0.0.0/8 my-tunnel
Defensive patterns

Strategy: validation

Validate before calling

// shell guard before invoking
if [ $# -lt 2 ]; then echo "usage: cloudflared tunnel route ip add <CIDR> <TUNNEL-ID>" >&2; exit 1; fi
cloudflared tunnel route ip add "$1" "$2"

Prevention

When it happens

Trigger: Running `cloudflared tunnel route ip add` with zero or one positional argument (missing the CIDR, the tunnel ID, or both).

Common situations: Forgetting the tunnel ID because the user assumed the currently-running tunnel is implied; shell quoting issues splitting the CIDR; habit from other CLIs where flags supply the tunnel.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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