caddyserver/caddy · error
invalid downstream address %s: %v
Error message
invalid downstream address %s: %v
What it means
The --from (downstream/listener) address of 'caddy reverse-proxy' failed httpcaddyfile.ParseAddress. This is the address Caddy serves on, and it must be a plain host/port/scheme combination; the '%v' carries the parse detail.
Source
Thrown at modules/caddyhttp/reverseproxy/command.go:112
internalCerts := fs.Bool("internal-certs")
accessLog := fs.Bool("access-log")
debug := fs.Bool("debug")
httpPort := strconv.Itoa(caddyhttp.DefaultHTTPPort)
httpsPort := strconv.Itoa(caddyhttp.DefaultHTTPSPort)
to, err := fs.GetStringSlice("to")
if err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("invalid to flag: %v", err)
}
if len(to) == 0 {
return caddy.ExitCodeFailedStartup, fmt.Errorf("--to is required")
}
// set up the downstream address; assume missing information from given parts
fromAddr, err := httpcaddyfile.ParseAddress(from)
if err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("invalid downstream address %s: %v", from, err)
}
if fromAddr.Path != "" {
return caddy.ExitCodeFailedStartup, fmt.Errorf("paths are not allowed: %s", from)
}
if fromAddr.Scheme == "" {
if fromAddr.Port == httpPort || fromAddr.Host == "" {
fromAddr.Scheme = "http"
} else {
fromAddr.Scheme = "https"
}
}
if fromAddr.Port == "" {
switch fromAddr.Scheme {
case "http":
fromAddr.Port = httpPort
case "https":
fromAddr.Port = httpsPort
}View on GitHub (pinned to 50e54ee279)
Solutions
- Use a simple value: domain, :port, or scheme://host:port, properly quoted.
- Fix the specific syntax error named by the wrapped message.
- Prefer 'caddy reverse-proxy --from localhost:8080' style during testing to minimize parse surface.
Example fix
# before caddy reverse-proxy --from 'exam ple.com:443' --to localhost:8080 # after caddy reverse-proxy --from 'example.com:443' --to localhost:8080
Defensive patterns
Strategy: validation
Validate before calling
if _, err := httpcaddyfile.ParseAddress(from); err != nil {
return fmt.Errorf("--from %q is not a valid site address: %v", from, err)
} Prevention
- Keep --from as domain, host:port, :port, or scheme://host:port — nothing else.
- Quote the flag value in shell scripts.
- Use 'caddy validate' equivalents (adapt/validate) when generating configs programmatically.
When it happens
Trigger: 'caddy reverse-proxy --from "ht!p://bad" ...' or addresses with invalid characters, bad brackets, or malformed port.
Common situations: Typos in the scheme, stray URL components, or unquoted shell metacharacters in --from.
Related errors
- paths are not allowed: %s
- invalid to flag: %v
- --to is required
- invalid upstream address %s: %v
- invalid header flag: %v
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/851e1a69936b4ca4.
Report an issue: GitHub.