# Installed Elastic-Agent cannot be removed

**URL:** <https://discuss.elastic.co/t/installed-elastic-agent-cannot-be-removed/350473>\
**Category:** Elastic Agent\
**Tags:** fleet\
**Created:** [January 5, 2024, 3:28pm UTC](https://discuss.elastic.co/t/installed-elastic-agent-cannot-be-removed/350473 "2024-01-05T15:28:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 5, 2024, 3:56pm UTC](https://discuss.elastic.co/t/installed-elastic-agent-cannot-be-removed/350473/5 "2024-01-05T15:56:47Z")

</div>

I agree, it's not a great way.... but it is _ **key** _ to run _ **the correct** _ uninstall command because the Agent Gets installed in `/opt/Elastic/Agent`, so the uninstall needs to run from there... hopefully that makes sense...

if you try to run it from the directory that you untarred into that will not work for sure and leave you in an inconsistent state...

Similar situation here

> [@Elastic agent uninstall](https://discuss.elastic.co/t/elastic-agent-uninstall/349659/5):
>
> I did this and now it is enrolled, topic can be closed rm /etc/systemd/system/elastic-agent.service root@elk:/opt/Elastic# rm -r Agent curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.11.2-linux-x86\_64.tar.gz tar xzvf elastic-agent-8.11.2-linux-x86\_64.tar.gz cd elastic-agent-8.11.2-linux-x86\_64 sudo ./elastic-agent install --url=https://:8220 --fleet-server-es=[https://localhost:9200](https://localhost:9200) --fleet-server-service-token= --fleet-server-policy=fleet-server-…

---

_[View the full topic](https://discuss.elastic.co/t/installed-elastic-agent-cannot-be-removed/350473)._
