Elastic agent uninstall

Hello,

it seeemed to be simple but, im trying to uninstall elastic agent, but unfortunately no luck

root@elk:/opt/elastic-agent-8.11.2-linux-x86_64# elastic-agent uninstall
Error: can only be uninstalled by executing the installed Elastic Agent at: /usr/bin/elastic-agent
For help, please see our troubleshooting guide at Troubleshoot common problems | Fleet and Elastic Agent Guide [8.11] | Elastic

root@elk:/opt/elastic-agent-8.11.2-linux-x86_64# /usr/bin/elastic-agent uninstall
Error: can only be uninstalled by executing the installed Elastic Agent at: /usr/bin/elastic-agent
For help, please see our troubleshooting guide at Troubleshoot common problems | Fleet and Elastic Agent Guide [8.11] | Elastic
root@elk:/opt/elastic-agent-8.11.2-linux-x86_64# cd /usr/bin/

root@elk:/usr/bin# elastic-agent uninstall
Error: can only be uninstalled by executing the installed Elastic Agent at: /usr/bin/elastic-agent
For help, please see our troubleshooting guide at Troubleshoot common problems | Fleet and Elastic Agent Guide [8.11] | Elastic

root@elk:/usr/bin# sudo elastic-agent uninstall
Error: can only be uninstalled by executing the installed Elastic Agent at: /usr/bin/elastic-agent
For help, please see our troubleshooting guide at Troubleshoot common problems | Fleet and Elastic Agent Guide [8.11] | Elastic

I have also tried to stop elastic-agent server, but no luck

What im doing wrong?

Thanks a lot

Hi @secsec
Exactly how did you install Elastic Agent?

What command did you run?

Did you try the exact command giving in the documents here?

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

Thanks, but unfortunately no luck

root@elk:/opt/elastic-agent-8.11.2-linux-x86_64# sudo /opt/Elastic/Agent/elastic-agent uninstall
Error: can only be uninstalled by executing the installed Elastic Agent at: /usr/bin/elastic-agent
For help, please see our troubleshooting guide at Troubleshoot common problems | Fleet and Elastic Agent Guide [8.11] | Elastic

You didn't answer the first question exactly how did you install?

Exactly what command did you run?

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
--fleet-server-service-token=
--fleet-server-policy=fleet-server-policy
--certificate-authorities=/etc/elasticsearch/certs/new/ca.pem
--fleet-server-es-ca=/etc/elasticsearch/certs/new/ca.pem
--fleet-server-cert=/etc/elasticsearch/certs/new/elasticsearch.crt
--fleet-server-cert-key=/etc/elasticsearch/certs/new/elasticsearch.key
--fleet-server-port=8220

thanks

1 Like

Yes, next time, you should run the correct command in the beginning, as I think you ended up in a half-uninstalled state.

Glad you got it fixed.

And yes, I have found when I have gotten in that state that re-installing you can get reset, and then when you want to uninstall next time, use the correct command.

It seems like a popular topic, but many threads are automatically closed without any elastic team response. One recommendation might be to document the uninstall warning/doc within the setup guide, especially for uninstall workflows that work differently than your other products.

Hi @optonpo, Welcome to the community...

A closed topic does not mean that it is not searchable.

Yes, I think we should perhaps we could make the warning clearer... on the other hand, the current documentation is pretty specific on what command to run to uninstall.

not to split hairs, but:

    • searching unanswered threads isn't that helpful
    • the install docs are flush with troubleshooting links which do not mention/link to un/reinstall workflow
    • i've spent all morning trying to figure out why the uninstall command below does not work

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

I really do appreciate the intel that is available-. just frustrated--that's all.

@optonpo

I have provided feedback to the Engineering team.... Mentioning this exact / your case... as well as the many others I have encountered.

They are looking at where / how to adjust the documentation to make it clearer... one of the engineers said he had done it himself...

Yes Exactly!! Understood...

BTW PR to get this fixed

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.