caddyserver/caddy · error
no config file to load; either use --config flag or ensure C
Error message
no config file to load; either use --config flag or ensure Caddyfile exists in current directory
What it means
From DetermineAdminAPIAddress: no --address was given, and the config-loading path (LoadConfig with the provided file/adapter, plus default Caddyfile discovery) turned up no config file at all, so there is no admin address to derive. The CLI refuses to guess beyond the default only after this lookup fails to find any config.
Source
Thrown at cmd/commandfuncs.go:883
return address, nil
}
// Try to load the config from file if specified, with the given adapter name
if configFile != "" {
var loadedConfigFile string
var err error
// use the provided loaded config if non-empty
// otherwise, load it from the specified file/adapter
loadedConfig := config
if len(loadedConfig) == 0 {
// get the config in caddy's native format
loadedConfig, loadedConfigFile, _, err = LoadConfig(configFile, configAdapter)
if err != nil {
return "", err
}
if loadedConfigFile == "" {
return "", fmt.Errorf("no config file to load; either use --config flag or ensure Caddyfile exists in current directory")
}
}
// get the address of the admin listener from the config
if len(loadedConfig) > 0 {
var tmpStruct struct {
Admin caddy.AdminConfig `json:"admin"`
}
err := json.Unmarshal(loadedConfig, &tmpStruct)
if err != nil {
return "", fmt.Errorf("unmarshaling admin listener address from config: %v", err)
}
if tmpStruct.Admin.Listen != "" {
return tmpStruct.Admin.Listen, nil
}
}
}
View on GitHub (pinned to 50e54ee279)
Solutions
- Pass --config /path/to/Caddyfile so the admin address can be discovered from it
- Or pass --address explicitly, e.g. --address localhost:2019
- Run the command from the directory containing the Caddyfile
Example fix
# before caddy reload # in a directory with no Caddyfile # after caddy reload --config /etc/caddy/Caddyfile
Defensive patterns
Strategy: validation
Validate before calling
# In scripts, resolve the config before calling the CLI:
CONFIG=${CONFIG:-/etc/caddy/Caddyfile}
[ -f "$CONFIG" ] || { echo "missing $CONFIG" >&2; exit 1; }
caddy reload --config "$CONFIG" Prevention
- Always pass --config in automation
- Run CLI commands from the directory holding the Caddyfile, or use absolute paths
When it happens
Trigger: Running a command that needs the admin address (e.g. reload) with neither --address, nor --config, nor a Caddyfile in the current directory; running from a directory different from where the Caddyfile lives.
Common situations: Running 'caddy reload' from $HOME while the service runs with /etc/caddy/Caddyfile; CI scripts that assume an adjacent Caddyfile that was not copied into the working directory.
Related errors
- invalid admin address %s: %v
- caddy responded with error: HTTP %d: %s
- reading config from file: %v
- no metrics registry found
- loading identity issuer modules: %s
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/527065ad12458fdd.
Report an issue: GitHub.