{"record":{"id":"ef7c54a833109dcf","repo":"cloudflare/cloudflared","slug":"cloudflared-service-is-already-installed-at-s-if","errorCode":null,"errorMessage":"cloudflared service is already installed at %s; if you are running a cloudflared tunnel, you can point it to multiple origins, avoiding the need to run more than one cloudflared service in the same machine; otherwise if you are really sure, you can do `cloudflared service uninstall` to clean up the existing service and then try again this command","messagePattern":"cloudflared service is already installed at (.+?); if you are running a cloudflared tunnel, you can point it to multiple origins, avoiding the need to run more than one cloudflared service in the same machine; otherwise if you are really sure, you can do `cloudflared service uninstall` to clean up the existing service and then try again this command","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/service_template.go","lineNumber":45,"sourceCode":"func (st *ServiceTemplate) ResolvePath() (string, error) {\n\tresolvedPath, err := homedir.Expand(st.Path)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error resolving path %s: %v\", st.Path, err)\n\t}\n\treturn resolvedPath, nil\n}\n\nfunc (st *ServiceTemplate) Generate(args *ServiceTemplateArgs) error {\n\ttmpl, err := template.New(st.Path).Parse(st.Content)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error generating %s template: %v\", st.Path, err)\n\t}\n\tresolvedPath, err := st.ResolvePath()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, err = os.Stat(resolvedPath); err == nil {\n\t\treturn errors.New(serviceAlreadyExistsWarn(resolvedPath))\n\t}\n\n\tvar buffer bytes.Buffer\n\terr = tmpl.Execute(&buffer, args)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error generating %s: %v\", st.Path, err)\n\t}\n\tfileMode := os.FileMode(0o644)\n\tif st.FileMode != 0 {\n\t\tfileMode = st.FileMode\n\t}\n\n\tplistFolder := filepath.Dir(resolvedPath)\n\terr = os.MkdirAll(plistFolder, 0o755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating %s: %v\", plistFolder, err)\n\t}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/service_template.go#L27-L63","documentation":"service_template.Generate renders the platform service definition (launchd plist, systemd unit, etc.) for `cloudflared service install`. Before writing, it stats the resolved destination path; if a file already exists there it refuses to overwrite and returns this descriptive error, protecting an existing cloudflared service from being clobbered.","triggerScenarios":"Running `cloudflared service install` (via installLaunchd on macOS or equivalent) when a service file already exists at /Library/LaunchD/com.cloudflare.cloudflared.plist (or the platform equivalent), typically from a previously installed cloudflared service.","commonSituations":"Reinstalling after upgrading without uninstalling; multiple tunnel configs on one machine each attempting service install; stale service file left behind by an incomplete uninstall.","solutions":["Run `sudo cloudflared service uninstall` first, then `cloudflared service install` again.","If the file is stale and no service exists, remove it manually (e.g. `sudo rm /Library/LaunchDaemons/com.cloudflare.cloudflared.plist`).","Serve multiple origins with one cloudflared service (multiple ingress rules) instead of installing multiple services on the same machine."],"exampleFix":"# before\nsudo cloudflared service install <token>   # fails: already installed\n# after\nsudo cloudflared service uninstall\nsudo cloudflared service install <token>","handlingStrategy":"fallback","validationCode":"const svcPath = \"/Library/LaunchDaemons/com.cloudflare.cloudflared.plist\"\nif _, err := os.Stat(svcPath); err == nil {\n    fmt.Println(\"service file exists; run `sudo cloudflared service uninstall` first\")\n    os.Exit(1)\n}","typeGuard":null,"tryCatchPattern":"if err := service.Generate(...); err != nil {\n    if strings.Contains(err.Error(), \"already installed\") {\n        // run uninstall then retry once\n        if uerr := uninstallService(); uerr == nil {\n            return service.Generate(...)\n        }\n    }\n    return err\n}","preventionTips":["Always pair installs with uninstall in upgrade runbooks.","Run only one cloudflared service per machine; consolidate origins via ingress rules.","Check `sudo cloudflared service status` before installing."],"tags":["service","install","filesystem","conflict"],"backgroundTag":"file-already-exists","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"}