# Fleet Server not starting with Elastic Agent (Error: fleet-server failed: context canceled)

**URL:** <https://discuss.elastic.co/t/fleet-server-not-starting-with-elastic-agent-error-fleet-server-failed-context-canceled/313662>\
**Category:** Beats\
**Tags:** fleet\
**Created:** [September 5, 2022, 8:43am UTC](https://discuss.elastic.co/t/fleet-server-not-starting-with-elastic-agent-error-fleet-server-failed-context-canceled/313662 "2022-09-05T08:43:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheshirecat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheshirecat/32/109532_2.png) [@cheshirecat](https://discuss.elastic.co/u/cheshirecat)\
**Post date:** [September 5, 2022, 8:43am UTC](https://discuss.elastic.co/t/fleet-server-not-starting-with-elastic-agent-error-fleet-server-failed-context-canceled/313662/1 "2022-09-05T08:43:51Z")

</div>

Hello There!  
I am trying to set up my fleet server and elastic agent.  
I am asked to do this:

```auto
sudo elastic-agent enroll --url=https://{{ip_address}}:{{port_number_1}} \
  --fleet-server-es=https://{{ip_address}}:{{port_number_2}} \
  --fleet-server-service-token=redacted \
  --fleet-server-policy=redacted \
--certificate-authorities=/etc/filebeat/elastic-stack-ca.pem --fleet-server-es-ca=/etc/elasticsearch/elastic-stack-ca.pem --fleet-server-cert=/etc/kibana/es.crt.pem --fleet-server-cert-key=/etc/kibana/es.key.pem

```

After firing command I am asked am I sure I want to continue:

```auto
This will replace your current settings. Do you want to continue? [Y/n]:y

```

And than this happens:

```auto
2022-09-05T10:33:40.599+0200	INFO	cmd/enroll_cmd.go:776	Fleet Server - Stopping
2022-09-05T10:34:42.627+0200	INFO	cmd/enroll_cmd.go:776	Fleet Server - Error - dial tcp 195.187.35.164:8220: connect: connection refused
Error: fleet-server failed: context canceled
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/7.17/fleet-troubleshooting.html

```

This is my `elastic-agent.yml`:

```auto
# ================================ General =====================================
# Beats is configured under Fleet, you can define most settings
# from the Kibana UI. You can update this file to configure the settings that
# are not supported by Fleet.
fleet:
  enabled: true

# agent.download:
# # source of the artifacts, requires elastic like structure and naming of the binari>
# # e.g /windows-x86.zip
# sourceURI: "https://artifacts.elastic.co/downloads/beats/"
# # path to the directory containing downloaded packages
# target_directory: "${path.data}/downloads"
# # timeout for downloading package
# timeout: 120s
# # file path to a public key used for verifying downloaded artifacts
# # if not file is present Elastic Agent will try to load public key from elastic.co >
# pgpfile: "${path.data}/elastic.pgp"
# # install_path describes the location of installed packages/programs. It is also us>
# # for reading program specifications.
# install_path: "${path.data}/install"

# agent.process:
# # minimal port number for spawned processes
# min_port: 10000
# # maximum port number for spawned processes
# max_port: 30000
# # timeout for creating new processes. when process is not successfully created by t>
# # start operation is considered a failure
# spawn_timeout: 30s

# agent.retry:
# # enabled determines whether retry is possible. Default is false.
# enabled: true
# # retries_count specifies number of retries. Default is 3.
# # Retry count of 1 means it will be retried one time after one failure.
# retries_count: 3
# # delay specifies delay in ms between retries. Default is 30s
# delay: 30s
# # max_delay specifies maximum delay in ms between retries. Default is 300s
# max_delay: 5m
# # Exponential determines whether delay is treated as exponential.
# # With 30s delay and 3 retries: 30, 60, 120s
# # Default is false
# exponential: false

```

I tried to compare my error with [docs](https://www.elastic.co/guide/en/fleet/7.17/fleet-troubleshooting.html) but I can't understand what is wrong.

---

<div class="post-metadata">

**Author:** ![mtojek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtojek/32/63863_2.png) [@mtojek](https://discuss.elastic.co/u/mtojek)\
**Post date:** [September 5, 2022, 2:52pm UTC](https://discuss.elastic.co/t/fleet-server-not-starting-with-elastic-agent-error-fleet-server-failed-context-canceled/313662/2 "2022-09-05T14:52:04Z")

</div>

Hi,

> dial tcp 195.187.35.164:8220: connect: connection refused

are you enable to hit this endpoint with telnet?

---

<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:** [October 3, 2022, 4:52pm UTC](https://discuss.elastic.co/t/fleet-server-not-starting-with-elastic-agent-error-fleet-server-failed-context-canceled/313662/3 "2022-10-03T16:52:18Z")

</div>

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