{"record":{"id":"c1163255399b4c56","repo":"caddyserver/caddy","slug":"to-is-required","errorCode":null,"errorMessage":"--to is required","messagePattern":"--to is required","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/reverseproxy/command.go","lineNumber":106,"sourceCode":"\tcaddy.TrapSignals()\n\n\tfrom := fs.String(\"from\")\n\tchangeHost := fs.Bool(\"change-host-header\")\n\tinsecure := fs.Bool(\"insecure\")\n\tdisableRedir := fs.Bool(\"disable-redirects\")\n\tinternalCerts := fs.Bool(\"internal-certs\")\n\taccessLog := fs.Bool(\"access-log\")\n\tdebug := fs.Bool(\"debug\")\n\n\thttpPort := strconv.Itoa(caddyhttp.DefaultHTTPPort)\n\thttpsPort := strconv.Itoa(caddyhttp.DefaultHTTPSPort)\n\n\tto, err := fs.GetStringSlice(\"to\")\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"invalid to flag: %v\", err)\n\t}\n\tif len(to) == 0 {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"--to is required\")\n\t}\n\n\t// set up the downstream address; assume missing information from given parts\n\tfromAddr, err := httpcaddyfile.ParseAddress(from)\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"invalid downstream address %s: %v\", from, err)\n\t}\n\tif fromAddr.Path != \"\" {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"paths are not allowed: %s\", from)\n\t}\n\tif fromAddr.Scheme == \"\" {\n\t\tif fromAddr.Port == httpPort || fromAddr.Host == \"\" {\n\t\t\tfromAddr.Scheme = \"http\"\n\t\t} else {\n\t\t\tfromAddr.Scheme = \"https\"\n\t\t}\n\t}\n\tif fromAddr.Port == \"\" {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/reverseproxy/command.go#L88-L124","documentation":"The 'caddy reverse-proxy' command was invoked without any --to flag (the slice parsed fine but is empty). --to defines the upstream backend address(es) and is mandatory, so Caddy exits with ExitCodeFailedStartup immediately.","triggerScenarios":"Running 'caddy reverse-proxy' with only --from, or omitting --to entirely; also typos like --dest that silently leave --to unset.","commonSituations":"Copy-pasting an example command and deleting the --to part; assuming the proxy forwards to a default port.","solutions":["Add --to pointing at the backend, e.g. 'caddy reverse-proxy --from example.com --to localhost:8080'.","Verify the flag name is exactly --to (not --upstream or --backend).","For multiple backends repeat or comma-separate values per the flag's slice semantics."],"exampleFix":"# before\ncaddy reverse-proxy --from example.com\n\n# after\ncaddy reverse-proxy --from example.com --to localhost:8080","handlingStrategy":"validation","validationCode":"if len(os.Args) > 0 { /* parse flags first */ }\nto := fs.StringSlice(\"to\", nil, \"upstream address\")\nif err := fs.Parse(os.Args[1:]); err != nil { return err }\nif len(*to) == 0 {\n    return fmt.Errorf(\"--to is required: specify the backend as host[:port] or scheme://host[:port]\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Checklist --from and --to together when scripting the quick command.","Use 'caddy reverse-proxy --help' to confirm flag names.","Wrap invocations in scripts that fail loudly on missing required flags."],"tags":["cli","reverse-proxy","flags","startup"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}