# Failed to submit message: 'Connection to APM Server timed out (url: http://localhost:8200/intake/v2/events, timeout: 5 seconds)'

**URL:** <https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835>\
**Category:** APM\
**Tags:** python, server\
**Created:** [July 28, 2022, 8:40am UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835 "2022-07-28T08:40:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaheen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaheen/32/108951_2.png) [@Shaheen](https://discuss.elastic.co/u/Shaheen)\
**Post date:** [July 28, 2022, 8:40am UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835/1 "2022-07-28T08:40:07Z")

</div>

**Kibana version** :8.3.2

**Elasticsearch version** : elastic-apm==6.10.1 (Django==4.0.5)

**APM Server version** :8.3.2

**APM Agent language and version** :Django==4.0.5

**Browser version** :Chrome

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:  
on `./manage.py elasticapm check`

> HTTP error while fetching server information: HTTPConnectionPool(host='localhost', port=8200): Max retries exceeded with url: / (Caused by NewConnectionError('\<urllib3.connection.HTTPConnection object at 0x7fc4ea8b5a90\>: Failed to establish a new connection: [Errno 111] Connection refused'))  
> Failed to submit message: 'Connection to APM Server timed out (url: [http://localhost:8200/intake/v2/events](http://localhost:8200/intake/v2/events), timeout: 5 seconds)

on `./manage.py elasticapm test`

> Oops. That didn't work. The following error occured:  
> HTTP error while fetching server information: HTTPConnectionPool(host='localhost', port=8200): Max retries exceeded with url: / (Caused by NewConnectionError('\<urllib3.connection.HTTPConnection object at 0x7f5ce7652d60\>: Failed to establish a new connection: [Errno 111] Connection refused'))  
> Failed to submit message: 'Connection to APM Server timed out (url: [http://localhost:8200/intake/v2/events](http://localhost:8200/intake/v2/events), timeout: 5 seconds)'

on django container getting

> Failed to submit message: 'Connection to APM Server timed out (url: [http://localhost:8200/intake/v2/events](http://localhost:8200/intake/v2/events), timeout: 5 seconds)'

configured using [Django support | APM Python Agent Reference [6.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/python/current/django-support.html#django-installation). documentation.

---

<div class="post-metadata">

**Author:** ![lahsivjar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lahsivjar/32/101451_2.png) [@lahsivjar](https://discuss.elastic.co/u/lahsivjar)\
**Post date:** [July 28, 2022, 2:58pm UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835/2 "2022-07-28T14:58:36Z")

</div>

Hi Shaheen,

Are you able to reach APM-Server by any process or agent? One possible cause might be that the `host` configuration on APM-Server is not configured to listen on `localhost`.

If the above doesn't help please share your APM-Server configuration and APM-Server logs so we can look further.

---

<div class="post-metadata">

**Author:** ![Shaheen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaheen/32/108951_2.png) [@Shaheen](https://discuss.elastic.co/u/Shaheen)\
**Post date:** [July 28, 2022, 6:33pm UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835/3 "2022-07-28T18:33:01Z")

</div>

these issue fixed by adding

```auto
ELASTIC_APM_SERVER_URL: http://apm-server:8200

```

this on .env  
but

> Failed to submit message: "Unable to reach APM Server: HTTPConnectionPool(host='apm-server', port=8200): Read timed out. (read timeout=5) (url: [http://apm-server:8200/intake/v2/events](http://apm-server:8200/intake/v2/events))"

this error is still on django logs

---

<div class="post-metadata">

**Author:** ![lahsivjar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lahsivjar/32/101451_2.png) [@lahsivjar](https://discuss.elastic.co/u/lahsivjar)\
**Post date:** [July 29, 2022, 5:03am UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835/4 "2022-07-29T05:03:20Z")

</div>

How/where are you running your APM-Server and django container? From our above correspondence, I suspect you are running them in docker.

If this is the case, I suspect that you are running apm-server in a separate docker network. You can try to connect your django container with the apm-server network by using `docker network connect <network_name> <container_name>` ([full ref](https://docs.docker.com/engine/reference/commandline/network_connect/)). You can get the list of network using `docker network ls`.

---

<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:** [August 19, 2022, 1:03am UTC](https://discuss.elastic.co/t/failed-to-submit-message-connection-to-apm-server-timed-out-url-http-localhost-8200-intake-v2-events-timeout-5-seconds/310835/5 "2022-08-19T01:03:38Z")

</div>

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