fatedier/frp · error

range number is invalid, %v

Error message

range number is invalid, %v

What it means

Thrown by frp's ParseRangeNumbers when a single-number element of a port/range string cannot be parsed as an int64. The function accepts comma-separated specs like "1000-2000,2001"; for a bare token (no '-' present) it runs strconv.ParseInt, and this site wraps that failure. The %v in the message carries the underlying strconv error, which names the offending token.

Source

Thrown at pkg/util/util/util.go:82

	return
}

func ParseRangeNumbers(rangeStr string) (numbers []int64, err error) {
	rangeStr = strings.TrimSpace(rangeStr)
	numbers = make([]int64, 0)
	// e.g. 1000-2000,2001,2002,3000-4000
	numRanges := strings.SplitSeq(rangeStr, ",")
	for numRangeStr := range numRanges {
		// 1000-2000 or 2001
		numArray := strings.Split(numRangeStr, "-")
		// length: only 1 or 2 is correct
		rangeType := len(numArray)
		switch rangeType {
		case 1:
			// single number
			singleNum, errRet := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
			if errRet != nil {
				err = fmt.Errorf("range number is invalid, %v", errRet)
				return
			}
			numbers = append(numbers, singleNum)
		case 2:
			// range numbers
			minValue, errRet := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
			if errRet != nil {
				err = fmt.Errorf("range number is invalid, %v", errRet)
				return
			}
			maxValue, errRet := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)
			if errRet != nil {
				err = fmt.Errorf("range number is invalid, %v", errRet)
				return
			}
			if maxValue < minValue {
				err = fmt.Errorf("range number is invalid")
				return

View on GitHub (pinned to 6c8a8d0a97)

Solutions

  1. Correct the string to pure comma-separated numbers/ranges: ports = "9000,9001,10000-10010"
  2. Remove trailing/leading commas and stray spaces (only TrimSpace around a token is allowed, not inside it)
  3. Check the %v detail in the message: strconv error shows exactly which token failed
  4. Validate config with `frpc verify` (or frpc verify -c ...) before deploying

Example fix

# before
ports = "9000,900l,10000-10010"

# after
ports = "9000,9001,10000-10010"
Defensive patterns

Strategy: validation

Validate before calling

var portRangeRe = regexp.MustCompile(`^\s*\d{1,19}\s*(?:-\s*\d{1,19}\s*)?(?:\s*,\s*\d{1,19}\s*(?:-\s*\d{1,19}\s*)?)*$`)

func validPortRange(s string) bool { return portRangeRe.MatchString(s) }

Prevention

When it happens

Trigger: Passing a ports/remotePort range string where a comma-separated element with no dash is not a valid integer: "2001abc", "", " 7 0x10"; also values exceeding int64 or containing a sign/format ParseInt rejects in base 10. Called for config fields like ports in frpc proxy configs.

Common situations: Typo in frpc.toml such as ports = "9000,900l" or a trailing comma creating an empty token; copy-pasting a range with unicode dash or spaces around numbers; feeding port numbers in hex or with units ("90k").

Related errors


AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15). Data as JSON: /api/errors/222f24639cf6fd73. Report an issue: GitHub.