AlistGo/alist · error

invalid port

Error message

invalid port

What it means

Returned by the convertToPorts closure that parses the FTP passive-port-range setting. For a range 'start-end' it requires end >= start, both ends within 1024-65535, and both numeric. On failure the caller logs 'failed to convert FTP PASV port mapper ...' at fatal level and the whole mapper function is not installed.

Source

Thrown at server/ftp.go:210

		ExposedStart  int
		ListenedStart int
		Length        int
	}
	groups := make([]group, len(pasvPortMappers))
	totalLength := 0
	convertToPorts := func(str string) (int, int, error) {
		start, end, multi := strings.Cut(str, "-")
		if multi {
			si, err := strconv.Atoi(start)
			if err != nil {
				return 0, 0, err
			}
			ei, err := strconv.Atoi(end)
			if err != nil {
				return 0, 0, err
			}
			if ei < si || ei < 1024 || si < 1024 || ei > 65535 || si > 65535 {
				return 0, 0, errors.New("invalid port")
			}
			return si, ei - si + 1, nil
		} else {
			ret, err := strconv.Atoi(str)
			if err != nil {
				return 0, 0, err
			} else {
				return ret, 1, nil
			}
		}
	}
	for i, mapper := range pasvPortMappers {
		var err error
		exposed, listened, mapped := strings.Cut(mapper, ":")
		for {
			if mapped {
				var es, ls, el, ll int
				es, el, err = convertToPorts(exposed)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Use a valid ascending range fully inside 1024-65535, e.g. '50000-50100'
  2. Remove spaces, quotes and stray commas/newlines from the setting value
  3. Restart AList after fixing; check the log for the 'port mapper will be ignored' fatal line to confirm it parsed

Example fix

// before
pasv: "50100 - 50000"
// after
pasv: "50000-50100"
Defensive patterns

Strategy: validation

Validate before calling

var pasvRange = regexp.MustCompile(`^[1-9][0-9]{3,4}-[1-9][0-9]{3,4}$`)
func validPasvRange(s string) bool {
    if !pasvRange.MatchString(s) { return false }
    lo, hi, _ := strings.Cut(s, "-")
    l, h := mustAtoi(lo), mustAtoi(hi)
    return l >= 1024 && h <= 65535 && h >= l
}

Prevention

When it happens

Trigger: The passive port setting contains a range like '50000-49999' (inverted), '80-443' or '21-1023' (below 1024, reserved for privileged ports), '1-70000' (above 65535), or non-numeric text such as '50000 - 50100' (spaces).

Common situations: Copying a docker -p mapping style value with spaces; trying to reuse ports below 1024 without realizing the validation forbids them; typos like '50100-50000'; trailing newline/comma fragments after editing the setting.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/375d6a26861d0b8c. Report an issue: GitHub.