{"record":{"id":"1cb570518a49cf10","repo":"cloudflare/cloudflared","slug":"tunnel-credentials-file-s-doesn-t-exist-or-is-n","errorCode":null,"errorMessage":"Tunnel credentials file '%s' doesn't exist or is not a file","messagePattern":"Tunnel credentials file '(.+?)' doesn't exist or is not a file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/credential_finder.go","lineNumber":39,"sourceCode":"// Implements CredFinder and looks for the credentials file at the given\n// filepath.\ntype staticPath struct {\n\tfilePath string\n\tfs       fileSystem\n}\n\nfunc newStaticPath(filePath string, fs fileSystem) CredFinder {\n\treturn staticPath{\n\t\tfilePath: filePath,\n\t\tfs:       fs,\n\t}\n}\n\nfunc (a staticPath) Path() (string, error) {\n\tif a.filePath != \"\" && a.fs.validFilePath(a.filePath) {\n\t\treturn a.filePath, nil\n\t}\n\treturn \"\", fmt.Errorf(\"Tunnel credentials file '%s' doesn't exist or is not a file\", a.filePath)\n}\n\n// Implements CredFinder and looks for the credentials file in several directories\n// searching for a file named <id>.json\ntype searchByID struct {\n\tid  uuid.UUID\n\tc   *cli.Context\n\tlog *zerolog.Logger\n\tfs  fileSystem\n}\n\nfunc newSearchByID(id uuid.UUID, c *cli.Context, log *zerolog.Logger, fs fileSystem) CredFinder {\n\treturn searchByID{\n\t\tid:  id,\n\t\tc:   c,\n\t\tlog: log,\n\t\tfs:  fs,\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/credential_finder.go#L21-L57","documentation":"staticPath is a CredFinder implementation that returns a fixed credentials-file path. Its Path() method returns this error when the configured path is empty or does not point to a readable regular file. Cloudflared needs the tunnel credentials JSON (containing the tunnel secret) to run a named tunnel.","triggerScenarios":"Running `cloudflared tunnel run --cred-file /path/to/creds.json` where the file does not exist, was deleted, or is a directory; or `TUNNEL_CRED_FILE` pointing at a non-file path.","commonSituations":"Credentials file deleted after tunnel cleanup, path typo, running cloudflared in a container without the credentials volume mounted, or copying the token but not the JSON credentials file to a new host.","solutions":["Verify the path with `ls -l <path>` and correct any typo in --cred-file or the credentials-file config field","Re-copy the <tunnel-id>.json credentials file from the machine that created the tunnel (`cloudflared tunnel token <name>` also works for remote-managed tunnels)","If the file is truly lost, delete the tunnel (`cloudflared tunnel delete <name>`) and create a new one with `cloudflared tunnel create <name>`"],"exampleFix":"// before\n$ cloudflared tunnel run --cred-file ~/.cloudflared/tunne1.json\n// error: Tunnel credentials file '~/.cloudflared/tunne1.json' doesn't exist or is not a file\n\n// after (fix typo or use the real ID)\n$ cloudflared tunnel run --cred-file ~/.cloudflared/6ff42ae2-765d-4adf-8336-94d006239e8e.json","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(credFile); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"credentials file %q missing or not a file\", credFile)\n}","typeGuard":"func credFileExists(p string) bool { fi, err := os.Stat(p); return err == nil && !fi.IsDir() }","tryCatchPattern":"path, err := credFinder.Path()\nif err != nil {\n    logger.Error().Err(err).Msg(\"cannot locate tunnel credentials\")\n    return err\n}","preventionTips":["Mount or copy credentials into containers/services before first run and verify with a startup healthcheck","Use `cloudflared tunnel token <name>` / remote-managed tunnels to avoid local JSON files entirely","Keep credentials named <tunnel-id>.json in ~/.cloudflared so default discovery finds them"],"tags":["file","configuration","tunnel"],"backgroundTag":"file-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}