caddyserver/caddy · error
bad response status code from http loader url: %v
Error message
bad response status code from http loader url: %v
What it means
attemptHttpCall accepts only 2xx-4xx as deliverable responses; anything below 200 or above 499 is closed and reported with this message. doHttpCallWithRetries then retries up to maxAttempts (10), so this error surfaces to Load only when the endpoint persistently returns 5xx (or an odd final 1xx) across all attempts.
Source
Thrown at caddyconfig/httploader.go:144
}
result, warnings, err := adaptByContentType(ct, body)
if err != nil {
return nil, err
}
for _, warn := range warnings {
ctx.Logger().Warn(warn.String())
}
return result, nil
}
func attemptHttpCall(client *http.Client, request *http.Request) (*http.Response, error) {
resp, err := client.Do(request) //nolint:gosec // no SSRF; comes from trusted config
if err != nil {
return nil, fmt.Errorf("problem calling http loader url: %v", err)
} else if resp.StatusCode < 200 || resp.StatusCode > 499 {
resp.Body.Close()
return nil, fmt.Errorf("bad response status code from http loader url: %v", resp.StatusCode)
}
return resp, nil
}
func doHttpCallWithRetries(ctx caddy.Context, client *http.Client, request *http.Request) (*http.Response, error) {
var resp *http.Response
var err error
const maxAttempts = 10
for i := range maxAttempts {
resp, err = attemptHttpCall(client, request)
if err != nil && i < maxAttempts-1 {
select {
case <-time.After(time.Millisecond * 500):
case <-ctx.Done():
return resp, ctx.Err()
}
} else {View on GitHub (pinned to 50e54ee279)
Solutions
- Check the config service health and logs; fix the server-side error it is returning.
- curl the URL to confirm the status; a proxy 502 usually means the upstream is down.
- Keep the endpoint returning 2xx for success; chronic 5xx will not be saved by the built-in 10 retries — fix availability instead of tuning retries.
Defensive patterns
Strategy: retry
Validate before calling
curl -s -o /dev/null -w '%{http_code}' "$CONFIG_URL" # should be 2xx; investigate 5xx upstream Prevention
- Monitor the config service for chronic 5xx; Caddy's built-in 10 attempts only cover blips.
- Make the endpoint idempotent and cheap so it never degrades into 502/503.
When it happens
Trigger: Config endpoint persistently returning 500/502/503 — crashing config service, bad gateway behind a proxy whose upstream is down — for 10 consecutive attempts.
Common situations: Config service behind a load balancer whose upstream is down; the service erroring while rendering the config; chronic upstream instability.
Related errors
- server responded with HTTP %d
- problem calling http loader url: %v
- HTTP %d fetching CA certificate bundle from %s
- got HTTP %d
- stopping admin server: %ds timeout
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/edb5a6b8780389c4.
Report an issue: GitHub.