fatedier/frp · error
failed to render template for proxy %s: %v
Error message
failed to render template for proxy %s: %v
What it means
While loading a legacy ini client config, every section named with the 'range:' prefix is expanded by renderRangeProxyTemplates into one concrete proxy section per port. This error wraps any failure of that expansion, including the port-validation errors from errors 155-157 or port-number parse failures from util.ParseRangeNumbers.
Source
Thrown at pkg/config/legacy/client.go:248
}
startAll := len(startProxy) == 0
// Build template sections from range section And append to ini.File.
rangeSections := make([]*ini.Section, 0)
for _, section := range f.Sections() {
if !strings.HasPrefix(section.Name(), "range:") {
continue
}
rangeSections = append(rangeSections, section)
}
for _, section := range rangeSections {
err = renderRangeProxyTemplates(f, section)
if err != nil {
return nil, nil, fmt.Errorf("failed to render template for proxy %s: %v", section.Name(), err)
}
}
for _, section := range f.Sections() {
name := section.Name()
if name == ini.DefaultSection || name == "common" || strings.HasPrefix(name, "range:") {
continue
}
_, shouldStart := startProxy[name]
if !startAll && !shouldStart {
continue
}
roleType := section.Key("role").String()
if roleType == "" {
roleType = "server"View on GitHub (pinned to 6c8a8d0a97)
Solutions
- Read the inner error — it pinpoints empty ports, invalid numbers, or count mismatch
- Set both local_port and remote_port in the [range:...] section using single values, comma lists, or a-b ranges
- Make both sides expand to the same number of ports (equal counts of comma-separated items and ranges)
- Validate numbers are decimal port values with no stray characters
Example fix
; before [range:web] type = tcp local_port = 6000-6002 remote_port = 7000-7001 ; count mismatch (3 vs 2) ; after [range:web] type = tcp local_port = 6000-6002 remote_port = 7000-7002
Defensive patterns
Strategy: validation
Validate before calling
for _, s := range file.Sections() {
if strings.HasPrefix(s.Name(), "range:") {
if s.Key("local_port").String() == "" || s.Key("remote_port").String() == "" {
return fmt.Errorf("%s: range section needs local_port and remote_port", s.Name())
}
}
} Prevention
- Pre-validate range sections for both port keys and equal expansion counts
- Use symmetric a-b ranges on both sides
- Run frpc verify (or the loader) in CI to catch range errors before deploy
When it happens
Trigger: A [range:xxx] section where local_port/remote_port is empty, non-numeric, uses a malformed range (e.g. '2000-1000-'), has mismatched counts ('local_port = 6000-6002' with 'remote_port = 7000-7001'), or where creating the derived section fails. The %s is the range section name, e.g. 'range:web'.
Common situations: Converting a single proxy to a range and forgetting one of the two port keys; typos like '600O' instead of '6000'; assuming ranges auto-pad counts; using commas inside a dash range.
Related errors
- invalid configuration file, not found [common] section
- local_port or remote_port is empty
- local ports number should be same with remote ports number
- local_port and remote_port is necessary
- local_port new key in section error: %v
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/e63d1d8057d4da14.
Report an issue: GitHub.