Loading

Uninstall Elastic Agents from edge hosts

To uninstall Elastic Agent, run the uninstall command from the directory where Elastic Agent is running.

Important

Be sure to run the uninstall command from a directory outside of where Elastic Agent is installed.

For example, on a Windows system the install location is C:\Program Files\Elastic\Agent. Run the uninstall command from C:\Program Files\Elastic or \tmp, or even your default home directory:

C:\"Program Files"\Elastic\Agent\elastic-agent.exe uninstall
Tip

You must run this command as the root user.

sudo /Library/Elastic/Agent/elastic-agent uninstall
Tip

You must run this command as the root user.

sudo /opt/Elastic/Agent/elastic-agent uninstall

Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select Run As Administrator).

From the PowerShell prompt, run:

C:\"Program Files"\Elastic\Agent\elastic-agent.exe uninstall

Follow the prompts to confirm that you want to uninstall Elastic Agent. The command stops and uninstalls any managed programs, such as Beats and Elastic Endpoint, before it stops and uninstalls Elastic Agent.

If you run into problems, refer to Troubleshoot common problems.

If you are using DEB or RPM, you can use the package manager to remove the installed package.

Note

For hosts enrolled in the Elastic Defend integration with Agent tamper protection enabled, you’ll need to include the uninstall token in the command, using the --uninstall-token flag. For more information, refer to Prevent Elastic Agent uninstallation.

You might need to remove Elastic Agent files manually if there’s a failure during installation.

To remove Elastic Agent manually from your system:

  1. Unenroll the agent if it’s managed by Fleet.

  2. For standalone agents, back up any configuration files you want to preserve.

  3. On your host, stop the agent. If any Elastic Agent-related processes are still running, stop them too.

    Tip

    Search for these processes and stop them if they’re still running: filebeat, metricbeat, fleet-server, and elastic-endpoint.

  4. Manually remove the Elastic Agent files from your system. For example, if you’re running Elastic Agent on macOS, delete /Library/Elastic/Agent/*. Not sure where the files are installed? Refer to Installation layout.

  5. If you’ve configured the Elastic Defend integration, also remove the files installed for endpoint protection. The directory structure is similar to Elastic Agent, for example, /Library/Elastic/Endpoint/*.

    Note

    When you remove the Elastic Defend integration from a macOS host (10.13, 10.14, or 10.15), the Endpoint System Extension is left on disk intentionally. If you want to remove the extension, refer to the documentation for your operating system.