# Fail to install Elastic-Agent

**URL:** <https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495>\
**Category:** Elastic Agent\
**Created:** [January 5, 2023, 1:34am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495 "2023-01-05T01:34:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pntmky](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pntmky](https://discuss.elastic.co/u/pntmky)\
**Post date:** [January 5, 2023, 1:34am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/1 "2023-01-05T01:34:52Z")

</div>

First of all, I installed Elastic Agent by DEB successfully, but I realize that cannot upgrade, so I uninstall Elastic Agent and remove installation layout of Elastic Agent.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/4/1424a01b7b1da399686369ffe54a189ff3df5081.png)  
And now when I install by Linux Tar, it fails and shows this error.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f93040ca25bdf57706b4e1ce21db99718f92357.png)

---

<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, 2023, 2:25am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/2 "2023-01-05T02:25:23Z")

</div>

Hi @pntmky Welcome to the community!

First please do not post images of text, they are hard to read, (some people can not read them at all) the can not be searched or debugged please post the text and format it.

> [@pntmky](#):
>
> so I uninstall Elastic Agent and remove installation layout of Elastic Agent.

Exactly How did you remove the elastic agent?

And did you stop it before ... perhaps it is still running... did you check?

Is there still an old `/usr/bin/elastic-agent` ?

---

<div class="post-metadata">

**Author:** ![pntmky](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pntmky](https://discuss.elastic.co/u/pntmky)\
**Post date:** [January 5, 2023, 2:28am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/3 "2023-01-05T02:28:32Z")

</div>

I removed elastic agent by command "rm -r" and folder /usr/bin/elastic-agent has been removed

---

<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, 2023, 3:19am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/4 "2023-01-05T03:19:12Z")

</div>

I think you should have used the package remove... Perhaps you should refer to the documention

> **[Uninstall Elastic Agents from edge hosts | Fleet and Elastic Agent Guide \[8.5\]...](https://www.elastic.co/guide/en/fleet/current/uninstall-elastic-agent.html)**

Perhaps run the uninstall manually

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

---

<div class="post-metadata">

**Author:** ![pntmky](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pntmky](https://discuss.elastic.co/u/pntmky)\
**Post date:** [January 5, 2023, 3:38am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/5 "2023-01-05T03:38:44Z")

</div>

I follow this guide to uninstall Elastic Agent. In step 4, I manually remove Elastic Agent files from my system, because I'm not sure where the files are installed, so I remove all files in installation layout locations by `rm -r` command. And now I cann't install Elastic Agent by Linux Tar since installation layout locations have been removed.

---

<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, 2023, 4:12am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/6 "2023-01-05T04:12:13Z")

</div>

I suspect perhaps you removed more than you should have...

> [@pntmky](#):
>
> and folder /usr/bin/elastic-agent has been removed

That is not a folder...

It's not clear what actually you have removed...

Are you still getting the same error?

Check the permissions on  
`/usr/bin/elastic-agent`

---

<div class="post-metadata">

**Author:** ![pntmky](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pntmky](https://discuss.elastic.co/u/pntmky)\
**Post date:** [January 5, 2023, 6:21am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/7 "2023-01-05T06:21:32Z")

</div>

`/usr/bin/elastic-agent` does not exist any more after I removed, I try to recreate it and copy content from other machine installed Elastic Agent successfully " **#!/bin/sh**  
**exec /opt/Elastic/Agent/elastic-agent $@**", but after that, it appears a new error that is " **/usr/bin/elastic-agent: 2: exec: /opt/Elastic/Agent/elastic-agent: not found**  
**Error: enroll command failed for unknown reason: exit status 127**". I continuously copy `/opt/Elastic/Agent` to create a new file but it fails, because it allows copy only `data` folder, vault folder and other files include `elastic-agent` cannot be copied, and I think each machine has a unique file elastic-agent. How do you know to create it again?

---

<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, 2023, 6:36am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/8 "2023-01-05T06:36:23Z")

</div>

I do not believe You can create it copy it by hand... I am not what you did when you cleaned up...

Perhaps reinstall via the deb package and then try to in remove using the deb package.

Then try again

---

<div class="post-metadata">

**Author:** ![pntmky](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pntmky](https://discuss.elastic.co/u/pntmky)\
**Post date:** [January 5, 2023, 7:46am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/9 "2023-01-05T07:46:33Z")

</div>

Thanks for your supporting, I uninstall by command `apt-get --purge` and check status to check for certain it stops and reinstall by Linux tar

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 2, 2023, 7:46am UTC](https://discuss.elastic.co/t/fail-to-install-elastic-agent/322495/10 "2023-02-02T07:46:44Z")

</div>

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