{"record":{"id":"774008be2cfb41be","repo":"caddyserver/caddy","slug":"invalid-admin-address-s-v","errorCode":null,"errorMessage":"invalid admin address %s: %v","messagePattern":"invalid admin address (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/commandfuncs.go","lineNumber":777,"sourceCode":"\n\tfor _, envfile := range envfileFlag {\n\t\tif err := loadEnvFromFile(envfile); err != nil {\n\t\t\treturn fmt.Errorf(\"loading additional environment variables: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// AdminAPIRequest makes an API request according to the CLI flags given,\n// with the given HTTP method and request URI. If body is non-nil, it will\n// be assumed to be Content-Type application/json. The caller should close\n// the response body. Should only be used by Caddy CLI commands which\n// need to interact with a running instance of Caddy via the admin API.\nfunc AdminAPIRequest(adminAddr, method, uri string, headers http.Header, body io.Reader) (*http.Response, error) {\n\tparsedAddr, err := caddy.ParseNetworkAddress(adminAddr)\n\tif err != nil || parsedAddr.PortRangeSize() > 1 {\n\t\treturn nil, fmt.Errorf(\"invalid admin address %s: %v\", adminAddr, err)\n\t}\n\torigin := \"http://\" + parsedAddr.JoinHostPort(0)\n\tif parsedAddr.IsUnixNetwork() {\n\t\torigin = \"http://127.0.0.1\" // bogus host is a hack so that http.NewRequest() is happy\n\n\t\t// the unix address at this point might still contain the optional\n\t\t// unix socket permissions, which are part of the address/host.\n\t\t// those need to be removed first, as they aren't part of the\n\t\t// resulting unix file path\n\t\taddr, _, err := internal.SplitUnixSocketPermissionsBits(parsedAddr.Host)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tparsedAddr.Host = addr\n\t} else if parsedAddr.IsFdNetwork() {\n\t\torigin = \"http://127.0.0.1\"\n\t}\n","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/commandfuncs.go#L759-L795","documentation":"Thrown by AdminAPIRequest when the admin endpoint address passed to the CLI cannot be parsed by caddy.ParseNetworkAddress, or when it expands to more than one port. The address must be a single, well-formed network address such as 'localhost:2019', '127.0.0.1:2019', or 'unix//run/caddy/admin.sock'. Any parse error is wrapped into this message along with the offending address.","triggerScenarios":"Calling any CLI command that talks to the admin API (reload, stop, list-modules, adapt via API, etc.) with --address set to a malformed value: empty host with bad port ('localhost:'), a port range like 'localhost:2019-2020', an unknown network prefix, or a stray scheme like 'http://localhost:2019'.","commonSituations":"Users prefixing http:// to the admin address (it is not a URL), copying a port range from a site address into the admin listen, or setting the admin listen in the config to a multi-port range and then running 'caddy reload --address ...'.","solutions":["Pass a plain host:port without a scheme, e.g. --address localhost:2019","Remove any port range; the admin endpoint must be exactly one port","For unix sockets use the unix/ prefix, e.g. unix//run/caddy/admin.sock","If the address comes from the config, fix the admin.listen value and reload"],"exampleFix":"# before\ncaddy reload --address http://localhost:2019\n\n# after\ncaddy reload --address localhost:2019","handlingStrategy":"validation","validationCode":"// Before invoking commands that hit the admin API, confirm the address parses\n// to exactly one port:\naddr, err := caddy.ParseNetworkAddress(adminAddr)\nif err != nil || addr.PortRangeSize() > 1 {\n    return fmt.Errorf(\"admin address %q must be a single host:port (no scheme, no port range)\", adminAddr)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never prefix the admin address with http:// or https://","Keep admin.listen a single port in configs consumed by the CLI","Omit --address and let Caddy read admin.listen from the config"],"tags":["cli","admin-api","network-address","configuration"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}