cloudflare/cloudflared · error

cloudflared service is already installed at ${service}; if y

Error message

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

What it means

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`.

Source

Thrown at cmd/cloudflared/windows_service.go:318

func installWindowsService(c *cli.Context) error {
	zeroLogger := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog)

	zeroLogger.Info().Msg("Installing cloudflared Windows service")
	exepath, err := os.Executable()
	if err != nil {
		return errors.Wrap(err, "Cannot find path name that start the process")
	}
	m, err := mgr.Connect()
	if err != nil {
		return errors.Wrap(err, "Cannot establish a connection to the service control manager")
	}
	defer m.Disconnect()
	s, err := m.OpenService(windowsServiceName)
	log := zeroLogger.With().Str(LogFieldWindowsServiceName, windowsServiceName).Logger()
	if err == nil {
		s.Close()
		return errors.New(serviceAlreadyExistsWarn(windowsServiceName))
	}
	var extraArgs []string
	if c.NArg() > 0 {
		// The service has been installed using a token e.g.,
		// $ cloudflared service install <token>
		//
		// Write the token file to a config directory so we can start the
		// service with --token-file.

		// Don't use :=, if we did so we would create a new err variable and
		// shadow the outer one, causing the defer below to not have access to
		// the outer err
		var configDir string
		configDir, err = getConfigDir()
		if err != nil {
			return fmt.Errorf("locate config dir: %w", err)
		}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Run `cloudflared service uninstall` (as Administrator) to remove the existing service, then reinstall
  2. Reconfigure the existing tunnel to point to multiple origins instead of installing a second service on the same machine
  3. If the service is orphaned, remove it manually: `sc.exe delete cloudflared` (with the correct service name), then retry
  4. Run the terminal as Administrator so the SCM check and removal succeed

Example fix

// before (fails)
C:\> cloudflared service install <TOKEN>
// error: cloudflared service is already installed at ...
// after
C:\> cloudflared service uninstall
C:\> cloudflared service install <TOKEN>
Defensive patterns

Strategy: validation

Validate before calling

:: Before installing, check whether the service exists
sc.exe query cloudflared >nul 2>&1 && (echo service already installed & exit /b 1)
cloudflared service install <TOKEN>

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/082ed780644a78c0. Report an issue: GitHub.