{"record":{"id":"5c71ecd26346f52a","repo":"caddyserver/caddy","slug":"caddy-responded-with-error-http-d-s","errorCode":null,"errorMessage":"caddy responded with error: HTTP %d: %s","messagePattern":"caddy responded with error: HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/commandfuncs.go","lineNumber":850,"sourceCode":"\t\tTransport: &http.Transport{\n\t\t\tDialContext: func(_ context.Context, _, _ string) (net.Conn, error) {\n\t\t\t\treturn net.Dial(parsedAddr.Network, parsedAddr.JoinHostPort(0))\n\t\t\t},\n\t\t},\n\t}\n\n\tresp, err := client.Do(req) //nolint:gosec // the only SSRF here would be self-sabotage I think\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"performing request: %v\", err)\n\t}\n\n\t// if it didn't work, let the user know\n\tif resp.StatusCode >= 400 {\n\t\trespBody, err := io.ReadAll(io.LimitReader(resp.Body, 1024*1024*2))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"HTTP %d: reading error message: %v\", resp.StatusCode, err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"caddy responded with error: HTTP %d: %s\", resp.StatusCode, respBody)\n\t}\n\n\treturn resp, nil\n}\n\n// DetermineAdminAPIAddress determines which admin API endpoint address should\n// be used based on the inputs. By priority: if `address` is specified, then\n// it is returned; if `config` is specified, then that config will be used for\n// finding the admin address; if `configFile` (and `configAdapter`) are specified,\n// then that config will be loaded to find the admin address; otherwise, the\n// default admin listen address will be returned.\nfunc DetermineAdminAPIAddress(address string, config []byte, configFile, configAdapter string) (string, error) {\n\t// Prefer the address if specified and non-empty\n\tif address != \"\" {\n\t\treturn address, nil\n\t}\n\n\t// Try to load the config from file if specified, with the given adapter name","sourceCodeStart":832,"sourceCodeEnd":868,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/commandfuncs.go#L832-L868","documentation":"The admin API responded with a 4xx/5xx status and this message surfaces that status plus the first 2 MiB of the body. It is the CLI's generic relay of server-side errors from operations like loading a config (caddy reload / caddy load), stopping, or reading endpoints.","triggerScenarios":"'caddy reload' with a config the running instance rejects (bad module names, invalid site addresses, provisioning failures); 'caddy stop' when already stopped (404 on /stop semantics); requesting a config path that does not exist.","commonSituations":"A Caddyfile that adapts fine but fails provisioning at runtime (e.g. TLS problem, port already bound by another process, unresolved module); reloading against a Caddy version lacking a module used in the config.","solutions":["Read the body text in the message — it names the exact server-side rejection cause","Validate the config first with: caddy validate --config <file>","Check the daemon logs for the stack behind the 4xx/5xx","Ensure the running binary includes the modules your config references (caddy list-modules)"],"exampleFix":"# before\ncaddy reload --config Caddyfile   # fails: caddy responded with error: HTTP 500 ...\n\n# after (catch config problems before reloading)\ncaddy validate --config Caddyfile && caddy adapt --config Caddyfile --adapter caddyfile | jq .\ncaddy reload --config Caddyfile","handlingStrategy":"validation","validationCode":"# Validate before applying, so server-side 4xx/5xx never happens:\ncaddy validate --config /etc/caddy/Caddyfile","typeGuard":null,"tryCatchPattern":"err := reload(); if err != nil && strings.Contains(err.Error(), \"caddy responded with error: HTTP 4\") { /* config rejected: surface body, keep previous config running */ }","preventionTips":["Make 'caddy validate' a required CI step for every config change","Parse the HTTP status and body out of the message for actionable logging","Remember a failed reload leaves the old config active — fix the cause, don't just retry"],"tags":["cli","admin-api","http-status","configuration"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}