cloudflare/cloudflared · info · ErrNoConfigFile
Cannot determine default configuration path. No file %v in %
Error message
Cannot determine default configuration path. No file %v in %v
What it means
ErrNoConfigFile is a sentinel error (exported var) indicating that none of the default configuration files (e.g. ~/.cloudflared/config.yml, /etc/cloudflared/config.yml, cloudflared defaults) could be located in the searched directories. It is not fatal: StartServer and ReadConfigFile return it to signal 'running with flags only', and cliutil/handler.go explicitly treats a match against it as an empty (no config) result.
Source
Thrown at config/configuration.go:38
"github.com/cloudflare/cloudflared/validation"
)
var (
// DefaultConfigFiles is the file names from which we attempt to read configuration.
DefaultConfigFiles = []string{"config.yml", "config.yaml"}
// DefaultUnixConfigLocation is the primary location to find a config file
DefaultUnixConfigLocation = "/usr/local/etc/cloudflared"
// DefaultUnixLogLocation is the primary location to find log files
DefaultUnixLogLocation = "/var/log/cloudflared"
// Launchd doesn't set root env variables, so there is default
// Windows default config dir was ~/cloudflare-warp in documentation; let's keep it compatible
defaultUserConfigDirs = []string{"~/.cloudflared", "~/.cloudflare-warp", "~/cloudflare-warp"}
defaultNixConfigDirs = []string{"/etc/cloudflared", DefaultUnixConfigLocation}
ErrNoConfigFile = fmt.Errorf("Cannot determine default configuration path. No file %v in %v", DefaultConfigFiles, DefaultConfigSearchDirectories())
)
const (
// BastionFlag is to enable bastion, or jump host, operation
BastionFlag = "bastion"
)
// DefaultConfigDirectory returns the default directory of the config file
func DefaultConfigDirectory() string {
if runtime.GOOS == "windows" {
path := os.Getenv("CFDPATH")
if path == "" {
path = filepath.Join(os.Getenv("ProgramFiles(x86)"), "cloudflared")
if _, err := os.Stat(path); os.IsNotExist(err) { // doesn't exist, so return an empty failure string
return ""
}
}
return pathView on GitHub (pinned to 2253eeeb25)
Solutions
- Create a config file at one of the default locations (e.g. ~/.cloudflared/config.yml) or pass --config /path/to/config.yml explicitly.
- If running token-managed tunnels, set TunnelTokenFlag (remotely-managed tunnel) so no local config file is needed.
- Compare the error against config.ErrNoConfigFile (errors.Is) to intentionally treat it as 'no config' rather than a failure.
- Verify HOME/USERPROFILE is set correctly when running under a service manager, or provide an absolute --config path.
Example fix
// before
inputSource, warnings, err := config.ReadConfigFile(c, log)
if err != nil { return err }
// after
inputSource, warnings, err := config.ReadConfigFile(c, log)
if err != nil {
if errors.Is(err, config.ErrNoConfigFile) { return "", nil }
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: check a config file exists before running
for _, p := range []string{"~/.cloudflared/config.yml", "/etc/cloudflared/config.yml"} {
if expanded, err := homedir.Expand(p); err == nil {
if _, err := os.Stat(expanded); err == nil { break }
}
}
// or pass --config explicitly Try / catch
inputSource, warnings, err := config.ReadConfigFile(c, log)
if err != nil {
if errors.Is(err, config.ErrNoConfigFile) { /* proceed flag-only */ } else { return err }
} Prevention
- Always pass --config with an absolute path in scripts and service units
- Compare against the exported sentinel with errors.Is instead of matching message text
- Set HOME/USERPROFILE correctly for service-managed runs
- Create the config file at a default location during provisioning
When it happens
Trigger: Calling config.ReadConfigFile, setFlagsFromConfigFile, or StartServer with no --config flag and no config file present in any of DefaultConfigSearchDirectories(). Also logged verbatim in tunnel/cmd.go when neither a config source nor a tunnel token is set.
Common situations: Running `cloudflared tunnel run <name>` expecting an ingress config that was never written to ~/.cloudflared/config.yml or /etc/cloudflared/config.yml; fresh container images; launchd/systemd environments where HOME differs so the user-level default dir is missed.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- too many addresses provided, max: 10
- No configuration file was found. Please create one, or use t
- ErrLogConfigurationIsInvalid
- ErrNoBaseURL
- ErrNoIngressRules
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/8146901105e0642c.
Report an issue: GitHub.