# ElasticAPM not working after xpack security enable

**URL:** <https://discuss.elastic.co/t/elasticapm-not-working-after-xpack-security-enable/250753>\
**Category:** APM\
**Tags:** elastic-stack-security\
**Created:** [October 2, 2020, 2:29am UTC](https://discuss.elastic.co/t/elasticapm-not-working-after-xpack-security-enable/250753 "2020-10-02T02:29:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ketan\_Juikar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ketan_juikar/32/45786_2.png) [@Ketan\_Juikar](https://discuss.elastic.co/u/Ketan_Juikar)\
**Post date:** [October 2, 2020, 2:29am UTC](https://discuss.elastic.co/t/elasticapm-not-working-after-xpack-security-enable/250753/1 "2020-10-02T02:29:25Z")

</div>

Hi after i enabled security fetaure in Elastic APM stooped working ,  
Client Error:-  
APM Server transport error (502): Unexpected APM Server response

````auto
elasticsearch.yml
   xpack.security.audit.enabled : true
  xpack.security.enabled : true
xpack.license.self_generated.type : basic```

Kibana.yml :
    xpack.security.enabled: true
   elasticsearch.username: elastic
   elasticsearch.password: pass

apm-server.yml
   output.elasticsearch:
           hosts: ["0.0.0.0:9200"]
           username : "elastic"
            password: "pass"

elastic agent script
  var apm = require('elastic-apm-node').start({
    serviceName: 'name',
    serverUrl: 'url'
  }); 

  var connect = require('connect')

// Add the Elastic APM middleware after your regular middleware
    app.use(apm.middleware.connect())

// ...but before any other error handler
    app.use(function (err, req, res, next) {
  // Custom error handling goes here
}); 

````

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [October 12, 2020, 6:42am UTC](https://discuss.elastic.co/t/elasticapm-not-working-after-xpack-security-enable/250753/2 "2020-10-12T06:42:59Z")

</div>

Hi,  
sorry for the late reply. From the configuration you posted I don't see any changes in the APM agent -\> server communication; do you see anything suspicious in the APM Server logs?

---

<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 9, 2020, 6:43am UTC](https://discuss.elastic.co/t/elasticapm-not-working-after-xpack-security-enable/250753/3 "2020-11-09T06:43:01Z")

</div>

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