{"record":{"id":"082ed780644a78c0","repo":"cloudflare/cloudflared","slug":"cloudflared-service-is-already-installed-at-serv","errorCode":null,"errorMessage":"cloudflared service is already installed at ${service}; 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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/windows_service.go","lineNumber":318,"sourceCode":"\nfunc installWindowsService(c *cli.Context) error {\n\tzeroLogger := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog)\n\n\tzeroLogger.Info().Msg(\"Installing cloudflared Windows service\")\n\texepath, err := os.Executable()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Cannot find path name that start the process\")\n\t}\n\tm, err := mgr.Connect()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Cannot establish a connection to the service control manager\")\n\t}\n\tdefer m.Disconnect()\n\ts, err := m.OpenService(windowsServiceName)\n\tlog := zeroLogger.With().Str(LogFieldWindowsServiceName, windowsServiceName).Logger()\n\tif err == nil {\n\t\ts.Close()\n\t\treturn errors.New(serviceAlreadyExistsWarn(windowsServiceName))\n\t}\n\tvar extraArgs []string\n\tif c.NArg() > 0 {\n\t\t// The service has been installed using a token e.g.,\n\t\t// $ cloudflared service install <token>\n\t\t//\n\t\t// Write the token file to a config directory so we can start the\n\t\t// service with --token-file.\n\n\t\t// Don't use :=, if we did so we would create a new err variable and\n\t\t// shadow the outer one, causing the defer below to not have access to\n\t\t// the outer err\n\t\tvar configDir string\n\t\tconfigDir, err = getConfigDir()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"locate config dir: %w\", err)\n\t\t}\n","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/windows_service.go#L300-L336","documentation":"installWindowsService checks the Windows Service Control Manager for an existing service with the same name before installing. If OpenService succeeds, a cloudflared service is already present, so installation is refused with this guidance message pointing to `cloudflared service uninstall`.","triggerScenarios":"Running `cloudflared service install ...` when a cloudflared Windows service with the same name already exists (previous install, another tunnel's service, or a leftover from an unclean removal).","commonSituations":"Reinstalling after a failed uninstall; wanting to run a second tunnel on the same machine without consolidating origins; installing under a different user without permissions to see/remove the old service.","solutions":["Run `cloudflared service uninstall` (as Administrator) to remove the existing service, then reinstall","Reconfigure the existing tunnel to point to multiple origins instead of installing a second service on the same machine","If the service is orphaned, remove it manually: `sc.exe delete cloudflared` (with the correct service name), then retry","Run the terminal as Administrator so the SCM check and removal succeed"],"exampleFix":"// before (fails)\nC:\\> cloudflared service install <TOKEN>\n// error: cloudflared service is already installed at ...\n// after\nC:\\> cloudflared service uninstall\nC:\\> cloudflared service install <TOKEN>","handlingStrategy":"validation","validationCode":":: Before installing, check whether the service exists\nsc.exe query cloudflared >nul 2>&1 && (echo service already installed & exit /b 1)\ncloudflared service install <TOKEN>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always uninstall before reinstalling: `cloudflared service uninstall`","Run terminals as Administrator for SCM operations","Consolidate multiple tunnels/origins into one service instead of installing duplicates","After failed uninstalls, verify removal with `sc.exe query cloudflared`"],"tags":["windows","service-installation","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-14T00:17:10.932Z"}