# Error sending data to APM server: Unexpected end of file from server, response code is -1

**URL:** <https://discuss.elastic.co/t/error-sending-data-to-apm-server-unexpected-end-of-file-from-server-response-code-is-1/247006>\
**Category:** APM\
**Tags:** docker, java\
**Created:** [August 31, 2020, 7:19pm UTC](https://discuss.elastic.co/t/error-sending-data-to-apm-server-unexpected-end-of-file-from-server-response-code-is-1/247006 "2020-08-31T19:19:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghesio](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@ghesio](https://discuss.elastic.co/u/ghesio)\
**Post date:** [August 31, 2020, 7:19pm UTC](https://discuss.elastic.co/t/error-sending-data-to-apm-server-unexpected-end-of-file-from-server-response-code-is-1/247006/1 "2020-08-31T19:19:31Z")

</div>

Hello! I'm experiencing this bug. I have the ELK stack configured with the APM server running on docker.

**Kibana version** : 7.8.0

**Elasticsearch version** : 7.8.0

**APM Server version** : 7.8.0

**APM Agent language and version** : Java - APM agent automatic discover 1.18.0.RC1

I have a Java JAX-RS service running in Jetty.

The app logs: `ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Error sending data to APM server: Unexpected end of file from server, response code is -1`

Even if the server is reachable from the host machine via `curl localhost:8200` which answers `curl: (52) Empty reply from server`

The agent is started using

```auto
	java -jar apm-agent-attach-standalone.jar \
    --continuous \
    --config service_name=MyName \
    --config server_urls=http://localhost:8200
	--config application_packages=com.my.package.resources

```

Which outputs:

```auto
2020-08-31 21:01:57.605 INFO Attaching the Elastic APM agent to 11748 null with arguments {service_name=MyName, server_urls=http://localhost:8200}
2020-08-31 21:01:58.458 INFO Done
2020-08-31 21:01:58.459 INFO Attaching the Elastic APM agent to 17008 null with arguments {service_name=MyName, server_urls=http://localhost:8200}
2020-08-31 21:01:58.469 INFO Done
2020-08-31 21:01:58.470 INFO Attaching the Elastic APM agent to 9232 null with arguments {service_name=MyName, server_urls=http://localhost:8200}
2020-08-31 21:01:58.476 INFO Done

```

Relevant section of `docker-compose.yml`:

```auto
  apm:
    build:
      context: apm/
      args:
        ELK_VERSION: $ELK_VERSION
    networks:
      - elk
    ports:
      - "8200:8200"
    depends_on:
      - other-dependance

```

`apm-server.yml`

```auto
output.elasticsearch:
  hosts: ["http://elasticsearch:9200"]
  username: "myuser"
  password: "mypassword"

apm-server.kibana.enabled: true
apm-server.kibana.host: "http://kibana:5601"

```

(`http://elasticsearch:9200` and `http://kibana:5601` are reachable)

The server itself is running on docker

```auto
...
2020-08-31T19:01:11.540Z INFO [publisher_pipeline_output] pipeline/output.go:152 Connection to backoff(elasticsearch(http://elasticsearch:9200)) established

```

And Kibana sees the server running

 ![immagine](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9c1a5ff7953720f3db4cc5552cbc6bbc2e9b09cf.png)

But no data is received

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

Am I missing something?

Thank you

---

<div class="post-metadata">

**Author:** ![ghesio](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@ghesio](https://discuss.elastic.co/u/ghesio)\
**Post date:** [August 31, 2020, 10:05pm UTC](https://discuss.elastic.co/t/error-sending-data-to-apm-server-unexpected-end-of-file-from-server-response-code-is-1/247006/2 "2020-08-31T22:05:14Z")

</div>

Resolved it. Had a misconfiguration in the DockerFile and it was missing from the configs `apm-server.host: "0.0.0.0:8200" as stated in the docs.

Also was issueing the wrong command. The correct one is: `java -jar apm-agent-attach-standalone.jar --config service_name=MyService server_urls=http://localhost:8200 application_packages=com.my.packageresources`

---

<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:** [September 21, 2020, 6:05pm UTC](https://discuss.elastic.co/t/error-sending-data-to-apm-server-unexpected-end-of-file-from-server-response-code-is-1/247006/3 "2020-09-21T18:05:34Z")

</div>

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