# Enroll command failed with exit code: 1

**URL:** <https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739>\
**Category:** Elasticsearch\
**Tags:** fleet\
**Created:** [October 10, 2023, 1:06pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739 "2023-10-10T13:06:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Claude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean-claude/32/7732_2.png) [@Jean-Claude](https://discuss.elastic.co/u/Jean-Claude)\
**Post date:** [October 10, 2023, 1:06pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/1 "2023-10-10T13:06:43Z")

</div>

Hello, i hope you are doing well  
This my infra

ELASTIC

```auto
v-elkmaster01.sys.u-bordeaux.fr
v-elkmaster02.sys.u-bordeaux.fr
v-elkmaster03.sys.u-bordeaux.fr
p-elkhot01.sys.u-bordeaux.fr
p-elkhot02.sys.u-bordeaux.fr
p-elkwarm01.sys.u-bordeaux.fr

```

KIBANA  
`v-kibana01.sys.u-bordeaux.fr`

Elastic has self-signed certificate  
kibana has public cerficate

For Elasitc and kibana all is good

Now i'm trying to set up a fleet server using kibana

FLEET  
`v-elkfleet01.sys.u-bordeaux.fr`  
has a public certificate

1. Login to Kibana and navigate to Fleet\>Agents tab.
2. 

```
Add host ip:https://elkfleet.sys.u-bordeaux.fr:8220.

```

3. 

```
Generate token and copy fleet server install command for windows.

```

4. 

```
Run agent install command and observe Error: enroll command failed with exit code: 1.

```

this is the command

```auto
 ./elastic-agent install --url=https://172.29.52.250:8220 \
  --fleet-server-es=https://172.29.52.38:9200 \
  --fleet-server-service-token= ************************************************ \
  --fleet-server-policy=fleet-server-policy \
  --fleet-server-es-ca-trusted-fingerprint= ******************************************* \
  --certificate-authorities=/etc/elasticsearch/certs/Chain_Intermediate_Root_Sectigo.crt \
  --fleet-server-cert=/etc/elasticsearch/certs/elkfleet_sys_u-bordeaux_fr.crt \
  --fleet-server-cert-key=/etc/elasticsearch/certs/elkfleet_sys_u-bordeaux_fr.key \
  --fleet-server-port=8220

```

And the logs

```auto
Elastic Agent will be installed at /opt/Elastic/Agent and will run as a service. Do you want to continue? [Y/n]:Y
{"log.level":"info","@timestamp":"2023-10-10T14:54:09.416+0200","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":807},"message":"Fleet Server - Starting","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-10-10T14:54:13.418+0200","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":807},"message":"Fleet Server - Waiting on fleet-server input to be added to policy: fleet-server-policy","ecs.version":"1.6.0"}
Error: fleet-server failed: context canceled
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.10/fleet-troubleshooting.html
Error: enroll command failed with exit code: 1
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.10/fleet-troubleshooting.html

```

---

<div class="post-metadata">

**Author:** ![Julia\_Bardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julia_bardi/32/79463_2.png) [@Julia\_Bardi](https://discuss.elastic.co/u/Julia_Bardi)\
**Post date:** [October 10, 2023, 1:25pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/2 "2023-10-10T13:25:31Z")

</div>

Hi Jean-Claude,

It seems something went wrong with the fleet-server-policy creation.  
Can you try to reset it with this API call from kibana console or curl?

```auto
POST kbn:/api/internal/fleet/reset_preconfigured_agent_policies/fleet-server-policy

```

And after check that the result of this query has the inputs array populated?

```auto
GET .fleet-policies/_search?q=policy_id:fleet-server-policy
{
  "size": 1, 
  "sort": [
    {
      "revision_idx": {
        "order": "desc"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![Jean-Claude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean-claude/32/7732_2.png) [@Jean-Claude](https://discuss.elastic.co/u/Jean-Claude)\
**Post date:** [October 10, 2023, 1:38pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/3 "2023-10-10T13:38:24Z")

</div>

Hello Julia  
Thanks for the reply

When i try this the reset command i got

```auto
{
  "statusCode": 404,
  "error": "Not Found",
  "message": "Not Found"
}

```

Is it normal ?

---

<div class="post-metadata">

**Author:** ![Jean-Claude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean-claude/32/7732_2.png) [@Jean-Claude](https://discuss.elastic.co/u/Jean-Claude)\
**Post date:** [October 10, 2023, 2:25pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/4 "2023-10-10T14:25:17Z")

</div>

I don't understand why after deleting the fleet-server-policy  
via kibana -\> fleet -\> agent policy  
i see nothing

but when icheck with

```auto
GET .fleet-policies/_search?q=policy_id:fleet-server-policy
{
  "size": 1, 
  "sort": [
    {
      "revision_idx": {
        "order": "desc"
      }
    }
  ]
}

```

I got a result

---

<div class="post-metadata">

**Author:** ![Julia\_Bardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julia_bardi/32/79463_2.png) [@Julia\_Bardi](https://discuss.elastic.co/u/Julia_Bardi)\
**Post date:** [October 10, 2023, 2:50pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/5 "2023-10-10T14:50:07Z")

</div>

The `.fleet-policies` index contains previous versions of the policy, even after deleted.  
The reset might not work if the agent policy was not preconfigured.  
You can try recreating a new agent policy with Fleet Server integration, and use the policy id when trying to enroll a Fleet Server.  
If you use the `Add Fleet Server` button on the UI, it should help guide with recreating the policy.

---

<div class="post-metadata">

**Author:** ![Jean-Claude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean-claude/32/7732_2.png) [@Jean-Claude](https://discuss.elastic.co/u/Jean-Claude)\
**Post date:** [October 10, 2023, 3:31pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/6 "2023-10-10T15:31:50Z")

</div>

Thanks a lot  
it was a problem with fleet-server-policy  
After creating a new policy with a new name  
it works

Best regards

---

<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:** [November 7, 2023, 3:31pm UTC](https://discuss.elastic.co/t/enroll-command-failed-with-exit-code-1/344739/7 "2023-11-07T15:31:58Z")

</div>

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