ECK Fleet APM Node.JS agent logs "APM Server transport error (ECONNREFUSED): connect ECONNREFUSED 127.0.0.1:8200"

I have installed and run ECK 8.7.1 with fleet:

$ k get agent
NAME            HEALTH   AVAILABLE   EXPECTED   VERSION   AGE
elastic-agent   green    6           6          8.7.1     84m
fleet-server    green    3           3          8.7.1     84m

Kibana version: 8.7.1

Elasticsearch version: 8.7.1

APM Server version: 8.7.1

APM Agent language and version: Node.JS "elastic-apm-node": "^3.45.0",

Browser version: chrome

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

Fresh install or upgraded from other version? Fresh

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
Whenever I click "Launch APM" button in Kibana, the following screen appears for a slit second and then disappears.

My application config:

var apm = require('elastic-apm-node').start({
  // Override service name from package.json
  // Allowed characters: a-z, A-Z, 0-9, -, _, and space
  serviceName: 'myapplication-apm',
  // Use if APM Server requires a token
  secretToken: '',
  // Use if APM Server uses API keys for authentication
  apiKey: '',
  // Set custom APM Server URL (default: http://127.0.0.1:8200)
  serverUrl: '',
  // Only activate the agent if it's running in production
  active: process.env.NODE_ENV === 'production'
})

My application log:

{"log.level":"error","@timestamp":"2023-05-05T07:42:34.295Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"APM Server transport error (ECONNREFUSED): connect ECONNREFUSED 127.0.0.1:8200"}

Steps to reproduce:
1.
2.
3.

Errors in browser console (if relevant):

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

Hi @Kok_How_Teh,

It looks like your APM agent is trying to connect to the default APM server URL. Can you check the address where your APM server is running and that it matches the value of the serverUrl property in your agent config?

Resolved. Thanks.

Please share the solution in the thread, it might help someone in future :slight_smile:

I'm assuming the issue was the serverUrl wasn't specified and therefore picking up the default, so the new config would look something like the below:

var apm = require('elastic-apm-node').start({
  // Override service name from package.json
  // Allowed characters: a-z, A-Z, 0-9, -, _, and space
  serviceName: 'myapplication-apm',
  // Use if APM Server requires a token
  secretToken: '',
  // Use if APM Server uses API keys for authentication
  apiKey: '',
  // Set custom APM Server URL (default: http://127.0.0.1:8200)
  serverUrl: 'http://my-apm-server:8200',
  // Only activate the agent if it's running in production
  active: process.env.NODE_ENV === 'production'
})

@Kok_How_Teh if that's not indeed the solution do let us know!

Yes, setting serverUrl and verifyServerCert: false is the solution. Thanks.

1 Like

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