# APM-Server 8.1 via Elastic-Agent 8.1 unable to connect to ElasticSearch 8.1

**URL:** <https://discuss.elastic.co/t/apm-server-8-1-via-elastic-agent-8-1-unable-to-connect-to-elasticsearch-8-1/300362>\
**Category:** Elasticsearch\
**Created:** [March 22, 2022, 3:15pm UTC](https://discuss.elastic.co/t/apm-server-8-1-via-elastic-agent-8-1-unable-to-connect-to-elasticsearch-8-1/300362 "2022-03-22T15:15:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gperdacher](https://avatars.discourse-cdn.com/v4/letter/g/bbce88/32.png) [@gperdacher](https://discuss.elastic.co/u/gperdacher)\
**Post date:** [March 22, 2022, 3:15pm UTC](https://discuss.elastic.co/t/apm-server-8-1-via-elastic-agent-8-1-unable-to-connect-to-elasticsearch-8-1/300362/1 "2022-03-22T15:15:22Z")

</div>

Hello,  
I installed

- Elasticsearch 8.1
- Kibana 8.1
- Fleet-Server 8.1  
on a debian 11 system with default settings.

Via Fleet-Server i installed/enrolled an elastic-agent with a policy and Elastic APM Integration 8.1.  
After start of elastic-agent

- APM-server is running on port 8200
- Elastic-server is running on port 9200

But APM-server could not connect to Elasticsearch. Should the api-key not be provided by fleet?  
In the file /var/lib/elastic-agent/data/elastic-agent-da4d9c/state.yml, I can find under outputs.default.api\_key a value, but this seems, that value is not used.

File /var/lib/elastic-agent/data/elastic-agent-da4d9c/install/apm-server-8.1.0-linux-x86\_64/apm\_server.yml is not configured properly, but I think this is not necessary, because of fleet-integration? And the other thing is, that I think, this file will be overridden on updates.

If I will test the connectivity from apm-agent, I am getting the following error (TLS has been disabled for testing)

```auto
:/var/lib/elastic-agent/data/elastic-agent-da4d9c/install/apm-server-8.1.0-linux-x86_64# ./apm-server test output   
elasticsearch: http://localhost:9200...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... OK
    addresses: 127.0.0.1
    dial up... OK
  TLS... WARN secure connection disabled
  talk to server... ERROR 401 Unauthorized: {"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}},"status":401}

```

Do you have a hint, where to configure this? Or should I use the apm-server standalone installation?

Regards,  
Gregor

---

<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:** [April 19, 2022, 3:16pm UTC](https://discuss.elastic.co/t/apm-server-8-1-via-elastic-agent-8-1-unable-to-connect-to-elasticsearch-8-1/300362/2 "2022-04-19T15:16:15Z")

</div>

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