{"record":{"id":"8146901105e0642c","repo":"cloudflare/cloudflared","slug":"cannot-determine-default-configuration-path-no-fi","errorCode":null,"errorMessage":"Cannot determine default configuration path. No file %v in %v","messagePattern":"Cannot determine default configuration path\\. No file (.+?) in (.+?)","errorType":"validation","errorClass":"ErrNoConfigFile","httpStatus":null,"severity":"info","filePath":"config/configuration.go","lineNumber":38,"sourceCode":"\t\"github.com/cloudflare/cloudflared/validation\"\n)\n\nvar (\n\t// DefaultConfigFiles is the file names from which we attempt to read configuration.\n\tDefaultConfigFiles = []string{\"config.yml\", \"config.yaml\"}\n\n\t// DefaultUnixConfigLocation is the primary location to find a config file\n\tDefaultUnixConfigLocation = \"/usr/local/etc/cloudflared\"\n\n\t// DefaultUnixLogLocation is the primary location to find log files\n\tDefaultUnixLogLocation = \"/var/log/cloudflared\"\n\n\t// Launchd doesn't set root env variables, so there is default\n\t// Windows default config dir was ~/cloudflare-warp in documentation; let's keep it compatible\n\tdefaultUserConfigDirs = []string{\"~/.cloudflared\", \"~/.cloudflare-warp\", \"~/cloudflare-warp\"}\n\tdefaultNixConfigDirs  = []string{\"/etc/cloudflared\", DefaultUnixConfigLocation}\n\n\tErrNoConfigFile = fmt.Errorf(\"Cannot determine default configuration path. No file %v in %v\", DefaultConfigFiles, DefaultConfigSearchDirectories())\n)\n\nconst (\n\t// BastionFlag is to enable bastion, or jump host, operation\n\tBastionFlag = \"bastion\"\n)\n\n// DefaultConfigDirectory returns the default directory of the config file\nfunc DefaultConfigDirectory() string {\n\tif runtime.GOOS == \"windows\" {\n\t\tpath := os.Getenv(\"CFDPATH\")\n\t\tif path == \"\" {\n\t\t\tpath = filepath.Join(os.Getenv(\"ProgramFiles(x86)\"), \"cloudflared\")\n\t\t\tif _, err := os.Stat(path); os.IsNotExist(err) { // doesn't exist, so return an empty failure string\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t}\n\t\treturn path","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ninputSource, warnings, err := config.ReadConfigFile(c, log)\nif err != nil { return err }\n// after\ninputSource, warnings, err := config.ReadConfigFile(c, log)\nif err != nil {\n    if errors.Is(err, config.ErrNoConfigFile) { return \"\", nil }\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// Go: check a config file exists before running\nfor _, p := range []string{\"~/.cloudflared/config.yml\", \"/etc/cloudflared/config.yml\"} {\n    if expanded, err := homedir.Expand(p); err == nil {\n        if _, err := os.Stat(expanded); err == nil { break }\n    }\n}\n// or pass --config explicitly","typeGuard":null,"tryCatchPattern":"inputSource, warnings, err := config.ReadConfigFile(c, log)\nif err != nil {\n    if errors.Is(err, config.ErrNoConfigFile) { /* proceed flag-only */ } else { return err }\n}","preventionTips":["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"],"tags":["configuration","config-file","sentinel-error"],"backgroundTag":"config-file-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}