# APM Server - Error Connection Refused

**URL:** <https://discuss.elastic.co/t/apm-server-error-connection-refused/177119>\
**Category:** APM\
**Created:** [April 16, 2019, 4:01pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119 "2019-04-16T16:01:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 16, 2019, 4:01pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/1 "2019-04-16T16:01:29Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

**Kibana version** :  
6.7.1

**Elasticsearch version** :  
6.7.1

**APM Server version** :  
6.7.1

**APM Agent language and version** :  
English  
elastic-apm-rum.umd.min.js v4.0.1 from github

**Browser version** :  
Chrome 71.0.3578.98

**OS Version** :  
Ubuntu 18.04 LTS

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:  
APT Repository

**Fresh install or upgraded from other version?**  
Fresh

**Is there anything special in your setup?**

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
Trying to setup up APM on simple Flask App. Python agent is working fine and we can see transactions in APM. The client-side is not interacting at all with the APM-Server. We are receiving ERR\_CONNECTION\_REFUSED error in the Chrome Debugger. Even though we have enabled RUM in the config file.

**Steps to reproduce** :  
1.Setup basic Flask App with only a blank button (button generates a random number sends it to python, in python number is squared then displayed in an alert on web app).  
2.Click button.  
3.Receive alert of randomly generated integer squared.  
4.Look in Chrome DevTools Console to see error.

**Errors in browser console (if relevant)**:  
elastic-apm-rum.umd.min.js:2 OPTIONS [http://localhost:8200/intake/v2/rum/events](http://localhost:8200/intake/v2/rum/events) net::ERR\_CONNECTION\_REFUSED

| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| --- | --- | --- | --- |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | r.(anonymous function) | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.\_makeHttpRequest | @ | elastic-apm-rum.umd.min.js:2 |
| | e.\_postJson | @ | elastic-apm-rum.umd.min.js:2 |
| | e.sendTransactions | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.flush | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | setTimeout (async) | | |
| | e.\_setTimer | @ | elastic-apm-rum.umd.min.js:2 |
| | e.add | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.addTransaction | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.applyAll | @ | elastic-apm-rum.umd.min.js:2 |
| | e.add | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | Promise.then (async) | | |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.runOuter | @ | elastic-apm-rum.umd.min.js:2 |
| | e.applyAsync | @ | elastic-apm-rum.umd.min.js:2 |
| | a.onEnd | @ | elastic-apm-rum.umd.min.js:2 |
| | e.callOnEnd | @ | elastic-apm-rum.umd.min.js:2 |
| | r.end | @ | elastic-apm-rum.umd.min.js:2 |
| | r.detectFinish | @ | elastic-apm-rum.umd.min.js:2 |
| | r.removeTask | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | setTimeout (async) | | |
| | i | @ | elastic-apm-rum.umd.min.js:2 |
| | load (async) | | |
| | e.\_sendPageLoadMetrics | @ | elastic-apm-rum.umd.min.js:2 |
| | e.init | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | (index):9 |

elastic-apm-rum.umd.min.js:2 Failed sending transactions! Error: [http://localhost:8200/intake/v2/rum/events](http://localhost:8200/intake/v2/rum/events) HTTP status: 0 at XMLHttpRequest.i.onreadystatechange (elastic-apm-rum.umd.min.js:2)

| | o.(anonymous function) | @ | elastic-apm-rum.umd.min.js:2 |
| --- | --- | --- | --- |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | Promise.then (async) | | |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.flush | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | setTimeout (async) | | |
| | e.\_setTimer | @ | elastic-apm-rum.umd.min.js:2 |
| | e.add | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.addTransaction | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.applyAll | @ | elastic-apm-rum.umd.min.js:2 |
| | e.add | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | Promise.then (async) | | |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | e.runOuter | @ | elastic-apm-rum.umd.min.js:2 |
| | e.applyAsync | @ | elastic-apm-rum.umd.min.js:2 |
| | a.onEnd | @ | elastic-apm-rum.umd.min.js:2 |
| | e.callOnEnd | @ | elastic-apm-rum.umd.min.js:2 |
| | r.end | @ | elastic-apm-rum.umd.min.js:2 |
| | r.detectFinish | @ | elastic-apm-rum.umd.min.js:2 |
| | r.removeTask | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | elastic-apm-rum.umd.min.js:2 |
| | setTimeout (async) | | |
| | i | @ | elastic-apm-rum.umd.min.js:2 |
| | load (async) | | |
| | e.\_sendPageLoadMetrics | @ | elastic-apm-rum.umd.min.js:2 |
| | e.init | @ | elastic-apm-rum.umd.min.js:2 |
| | (anonymous) | @ | (index):9 |

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![Hamidreza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamidreza/32/21369_2.png) [@Hamidreza](https://discuss.elastic.co/u/Hamidreza)\
**Post date:** [April 24, 2019, 11:59am UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/2 "2019-04-24T11:59:59Z")

</div>

Hi,

Welcome to our forum.

It seems that the preflight (OPTIONS) request is failing. This could be because of misconfiguration on the APM Server.  
Would you please post the content of your APM Server configuration file?

Cheers,  
Hamid

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 24, 2019, 8:04pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/3 "2019-04-24T20:04:13Z")

</div>

################### APM Server Configuration #########################

############################# APM Server ######################################

apm-server:

# Defines the host and port the server is listening on. use "unix:/path/to.sock" to listen on a unix domain socket.

host: "localhost:8200"

# Maximum permitted size in bytes of a request's header accepted by the server to be processed.

#max\_header\_size: 1048576

# Maximum permitted duration for reading an entire request.

#read\_timeout: 30s

# Maximum permitted duration for writing a response.

#write\_timeout: 30s

# Maximum duration in seconds before releasing resources when shutting down the server.

#shutdown\_timeout: 5s

#-- v1 Intake API (deprecated)

# Maximum permitted size in bytes of an unzipped request accepted by the server to be processed.

#max\_unzipped\_size: 31457280

# Maximum duration request will be queued before being read.

#max\_request\_queue\_time: 2s

# Maximum number of requests permitted to be sent to the server concurrently.

#concurrent\_requests: 5

#-- v2 Intake API

# Maximum allowed size in bytes of a single event

#max\_event\_size: 307200

#--

# Maximum number of new connections to accept simultaneously (0 means unlimited)

# max\_connections: 0

# Authorization token to be checked. If a token is set here the agents must

# send their token in the following format: Authorization: Bearer .

# It is recommended to use an authorization token in combination with SSL enabled,

# and save the token in the beats keystore.

secret\_token: "HCBE"  
#ssl.enabled: false  
#ssl.certificate : "path/to/cert"  
#ssl.key : "path/to/private\_key"

# It is recommended to use the provided keystore instead of entering the passphrase in plain text.

#ssl.key\_passphrase: ""

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 24, 2019, 8:04pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/4 "2019-04-24T20:04:37Z")

</div>

rum:  
# To enable real user monitoring (RUM) support set this to true.  
enabled: true

```
#-- v1 RUM endpoint (deprecated)

# Rate limit per second and IP address for requests sent to the RUM endpoint.
#rate_limit: 10

#-- v2 RUM endpoint

#event_rate:

  # Defines the maximum amount of events allowed to be sent to the APM Server v2 RUM
  # endpoint per ip per second. Defaults to 300.
  #limit: 300

  # An LRU cache is used to keep a rate limit per IP for the most recently seen IPs.
  # This setting defines the number of unique IPs that can be tracked in the cache.
  # Sites with many concurrent clients should consider increasing this limit. Defaults to 1000.
  #lru_size: 1000

#-- General RUM settings

# Comma separated list of permitted origins for real user monitoring.
# User-agents will send an origin header that will be validated against this list.
# An origin is made of a protocol scheme, host and port, without the url path.
# Allowed origins in this setting can have * to match anything (eg.: http://*.example.com)
# If an item in the list is a single '*', everything will be allowed
allow_origins : ['*']

# Regexp to be matched against a stacktrace frame's `file_name` and `abs_path` attributes.
# If the regexp matches, the stacktrace frame is considered to be a library frame.
#library_pattern: "node_modules|bower_components|~"

# Regexp to be matched against a stacktrace frame's `file_name`.
# If the regexp matches, the stacktrace frame is not used for calculating error groups.
# The default pattern excludes stacktrace frames that have a filename starting with '/webpack'
#exclude_from_grouping: "^/webpack"

# If a source map has previously been uploaded, source mapping is automatically applied
# to all error and transaction documents sent to the RUM endpoint.
#source_mapping:

  # Source maps are always fetched from Elasticsearch, by default using the output.elasticsearch configuration.
  # A different instance must be configured when using any other output.
  # This setting only affects sourcemap reads - the output determines where sourcemaps are written.
  #elasticsearch:
    # Array of hosts to connect to.
    # Scheme and port can be left out and will be set to the default (http and 9200)
    # In case you specify and additional path, the scheme is required: http://localhost:9200/path
    # IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
    # hosts: ["localhost:9200"]

    # Optional protocol and basic auth credentials.
    #protocol: "https"
    #username: "elastic"
    #password: "changeme"

  # The `cache.expiration` determines how long a source map should be cached before fetching it again from Elasticsearch.
  # Note that values configured without a time unit will be interpreted as seconds.
  #cache:
    #expiration: 5m

  # Source maps are stored in a seperate index.
  # If the default index pattern for source maps at 'outputs.elasticsearch.indices'
  # is changed, a matching index pattern needs to be specified here.
  #index_pattern: "apm-*-sourcemap*"

```

# If set to true, APM Server augments data received by the agent with the original IP of the backend server,

# or the IP and User Agent of the real user (RUM requests). It defaults to true.

#capture\_personal\_data: true

# golang expvar support - [https://golang.org/pkg/expvar/](https://golang.org/pkg/expvar/)

#expvar:  
# Set to true to Expose expvar  
#enabled: false

```
# Url to expose expvar
#url: "/debug/vars"

```

# Instrumentation support for the server's HTTP endpoints and event publisher.

#instrumentation:  
# Set to true to enable instrumentation of the APM server itself.  
#enabled: false  
# Environment in which the APM Server is running on (eg: staging, production, etc.)  
#environment: ""  
# Remote host to report instrumentation results to. Single entry permitted until  
# [https://github.com/elastic/apm-agent-go/issues/200](https://github.com/elastic/apm-agent-go/issues/200) is resolved.  
#hosts:  
# - [http://remote-apm-server:8200](http://remote-apm-server:8200)  
# Remote apm-servers' secret\_token  
#secret\_token:

# Metrics endpoint

#metrics:  
# Set to false to disable the metrics endpoint  
#enabled: true

# A pipeline is a definition of processors applied to documents when writing them to Elasticsearch.

# Using pipelines involves two steps:

# (1) registering a pipeline

# (2) applying a pipeline during data ingestion (see `output.elasticsearch.pipelines`)

# 

# You can manually register pipelines, or use this configuration option to ensure

# pipelines are loaded and registered at the configured Elasticsearch instances.

# Automatic pipeline registration requires

# \* `output.elasticsearch` to be enabled and configured.

# \* having the required Elasticsearch Processor Plugins installed.

# APM Server default pipelines require you to have the `Ingest User Agent Plugin` installed.

# Find the default pipeline configuration at `ingest/pipeline/definition.json`.

# 

#register.ingest.pipeline:  
# Registers pipeline definitions in Elasticsearch on APM Server startup. Defaults to false.  
#enabled: false

```
# Overwrites existing pipeline definitions in Elasticsearch. Defaults to true.
#overwrite: true
```

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 24, 2019, 8:05pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/5 "2019-04-24T20:05:39Z")

</div>

#================================ General ======================================

# Internal queue configuration for buffering events to be published.

#queue:

# Queue type by name (default 'mem')

# The memory queue will present all available events (up to the outputs

# bulk\_max\_size) to the output, the moment the output is ready to server

# another batch of events.

#mem:  
# Max number of events the queue can buffer.  
#events: 4096

```
# Hints the minimum number of events stored in the queue,
# before providing a batch of events to the outputs.
# A value of 0 (the default) ensures events are immediately available
# to be sent to the outputs.
#flush.min_events: 2048

# Maximum duration after which events are available to the outputs,
# if the number of events stored in the queue is < min_flush_events.
#flush.timeout: 1s

```

# Sets the maximum number of CPUs that can be executing simultaneously. The

# default is the number of logical CPUs available in the system.

#max\_procs:

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch

# By default template loading is enabled and the template is loaded.

# These settings can be adjusted to load your own template or overwrite existing ones.

# Set to false to disable template loading.

#setup.template.enabled: true

# Template name. By default the template name is "apm-%{[beat.version]}"

# The template name and pattern has to be set in case the elasticsearch index pattern is modified.

#setup.template.name: "apm-%{[beat.version]}"

# Template pattern. By default the template pattern is "apm-%{[beat.version]}-\*" to apply to the default index settings.

# The first part is the version of the beat and then -\* is used to match all daily indices.

# The template name and pattern has to be set in case the elasticsearch index pattern is modified.

#setup.template.pattern: "apm-%{[beat.version]}-\*"

# Path to fields.yml file to generate the template

#setup.template.fields: "${path.config}/fields.yml"

# Overwrite existing template

#setup.template.overwrite: false

# Elasticsearch template settings

#setup.template.settings:

# A dictionary of settings to place into the settings.index dictionary

# of the Elasticsearch template. For more details, please check

# [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html)

#index:  
#number\_of\_shards: 1  
#codec: best\_compression  
#number\_of\_routing\_shards: 30  
#mapping.total\_fields.limit: 2000

# A dictionary of settings for the \_source field. For more details, please check

# [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html)

#\_source:  
#enabled: false

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 24, 2019, 8:05pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/6 "2019-04-24T20:05:55Z")

</div>

#============================== Deprecated: Dashboards =====================================

# 

# Deprecated: Loading dashboards from the APM Server into Kibana is deprecated from 6.4 on.

# We suggest to use the Kibana UI to load APM Server dashboards and index pattern instead.

# 

# These settings control loading the sample dashboards to the Kibana index. Loading

# the dashboards are disabled by default and can be enabled either by setting the

# options here, or by using the `-setup` CLI flag or the `setup` command.

#setup.dashboards.enabled: false

# The directory from where to read the dashboards. The default is the `kibana`

# folder in the home path.

#setup.dashboards.directory: ${path.home}/kibana

# The URL from where to download the dashboards archive. It is used instead of

# the directory if it has a value.

#setup.dashboards.url:

# The file archive (zip file) from where to read the dashboards. It is used instead

# of the directory when it has a value.

#setup.dashboards.file:

# The name of the Kibana index to use for setting the configuration. Default is ".kibana"

#setup.dashboards.kibana\_index: .kibana

# The Elasticsearch index name. This overwrites the index name defined in the

# dashboards and index pattern. Example: testbeat-\*

# The dashboards.index needs to be changed in case the elasticsearch index pattern is modified.

#setup.dashboards.index:

# Always use the Kibana API for loading the dashboards instead of autodetecting

# how to install the dashboards by first querying Elasticsearch.

#setup.dashboards.always\_kibana: false

# If true and Kibana is not reachable at the time when dashboards are loaded,

# it will retry to reconnect to Kibana instead of exiting with an error.

#setup.dashboards.retry.enabled: false

# Duration interval between Kibana connection retries.

#setup.dashboards.retry.interval: 1s

# Maximum number of retries before exiting with an error, 0 for unlimited retrying.

#setup.dashboards.retry.maximum: 0

#============================== Deprecated: Kibana =====================================

# Deprecated: Starting with APM Server version 6.4, loading dashboards and index pattern

# from the APM Server into Kibana is deprecated.

# We suggest to use the Kibana UI to load APM Server dashboards and index pattern instead.

# 

# Setting up a Kibana endpoint is not necessary when loading the index pattern and dashboards via the UI.

#setup.kibana:

# Kibana Host

# Scheme and port can be left out and will be set to the default (http and 5601)

# In case you specify and additional path, the scheme is required: [http://localhost:5601/path](http://localhost:5601/path)

# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601

#host: "localhost:5601"

# Optional protocol and basic auth credentials.

#protocol: "https"  
#username: "elastic"  
#password: "changeme"

# Optional HTTP Path

#path: ""

# Use SSL settings for HTTPS. Default is false.

#ssl.enabled: false

# Configure SSL verification mode. If `none` is configured, all server hosts

# and certificates will be accepted. In this mode, SSL based connections are

# susceptible to man-in-the-middle attacks. Use only for testing. Default is

# `full`.

#ssl.verification\_mode: full

# List of supported/valid TLS versions. By default all TLS versions 1.0 up to

# 1.2 are enabled.

#ssl.supported\_protocols: [TLSv1.0, TLSv1.1, TLSv1.2]

# SSL configuration. By default is off.

# List of root certificates for HTTPS server verifications

#ssl.certificate\_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication

#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key

#ssl.key: "/etc/pki/client/cert.key"

# Optional passphrase for decrypting the Certificate Key.

# It is recommended to use the provided keystore instead of entering the passphrase in plain text.

#ssl.key\_passphrase: ''

# Configure cipher suites to be used for SSL connections

#ssl.cipher\_suites:

# Configure curve types for ECDHE based cipher suites

#ssl.curve\_types:

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 24, 2019, 8:06pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/7 "2019-04-24T20:06:34Z")

</div>

IF you want a txt file so its easier to read, please provide me with email and I will send it too you

---

<div class="post-metadata">

**Author:** ![Hamidreza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamidreza/32/21369_2.png) [@Hamidreza](https://discuss.elastic.co/u/Hamidreza)\
**Post date:** [April 25, 2019, 7:54am UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/8 "2019-04-25T07:54:37Z")

</div>

Hi,

Are you running your browser in a different machine to the one running APM Server? If that's the case you should set `host:0.0.0.0:8200` to make sure APM Server is accessible remotely. Furthermore you should configure the RUM agent with the correct `serverUrl`.

I've also send you my email on the PM.

Cheers,  
Hamid

---

<div class="post-metadata">

**Author:** ![rtpatel95](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@rtpatel95](https://discuss.elastic.co/u/rtpatel95)\
**Post date:** [April 25, 2019, 2:42pm UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/9 "2019-04-25T14:42:39Z")

</div>

Hi Hamid,

Still having issues, sent email to further clarify and attach config file.

---

<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:** [May 16, 2019, 10:42am UTC](https://discuss.elastic.co/t/apm-server-error-connection-refused/177119/10 "2019-05-16T10:42:48Z")

</div>

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