cloudflare/cloudflared · error

not a valid url

Error message

not a valid url

What it means

getAppURL extracts the target URL needed to fetch an Access token; when the caller supplied no command arguments it returns this error after logging guidance. It precedes URL parsing, so it strictly means 'no URL was provided', not that a given URL was malformed (that path returns processURL's error instead).

Source

Thrown at cmd/cloudflared/access/cmd.go:470

		return err
	}
	cfdToken, err := token.FetchTokenWithRedirect(fetchTokenURL, appInfo, c.Bool(cfdflags.AutoCloseInterstitial), c.Bool(fedrampFlag), log)
	if err != nil {
		return err
	}

	if err := sshgen.GenerateShortLivedCertificate(originURL, cfdToken); err != nil {
		return err
	}

	return nil
}

// getAppURL will pull the request URL needed for fetching a user's Access token
func getAppURL(cmdArgs []string, log *zerolog.Logger) (*url.URL, error) {
	if len(cmdArgs) < 1 {
		log.Error().Msg("Please provide a valid URL as the first argument to curl.")
		return nil, errors.New("not a valid url")
	}

	u, err := processURL(cmdArgs[0])
	if err != nil {
		log.Error().Msg("Please provide a valid URL as the first argument to curl.")
		return nil, err
	}

	return u, err
}

// parseAllowRequest will parse cmdArgs and return a copy of the args and result
// of the allow request was present
func parseAllowRequest(cmdArgs []string) ([]string, bool) {
	if len(cmdArgs) > 1 {
		if cmdArgs[0] == "--allow-request" || cmdArgs[0] == "-ar" {
			return cmdArgs[1:], true
		}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Supply the application URL as the first argument to `cloudflared access curl`
  2. Validate argument count in wrapper scripts before invoking cloudflared
  3. If you get a different error after adding the URL, fix the URL scheme/format itself (see processURL errors)

Example fix

// before
# cloudflared access curl
// after
# cloudflared access curl https://app.example.com
Defensive patterns

Strategy: validation

Validate before calling

if len(args) < 1 || args[0] == "" {
    return errors.New("first argument to `cloudflared access curl` must be the app URL")
}

Try / catch

u, err := getAppURL(cmdArgs, log)
if err != nil {
    if strings.Contains(err.Error(), "not a valid url") {
        return fmt.Errorf("provide the app URL as the first argument: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling getAppURL (via `cloudflared access curl`) with an empty cmdArgs slice — the first argument that should hold the URL is missing.

Common situations: Automation scripts invoking access curl without the URL argument; argument-shifting bugs where flags consume the URL; users omitting the URL because plain `curl` defaults differently.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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