Skip to content

ECONNREFUSED on Node.js example #724

@aduh95

Description

@aduh95

Description

The logs do not reach the NewRelic dashboard, and it complains about not being able to connect to a local port.

Steps to Reproduce

As described in the README, set the env var, change the address because I'm in the EU, run npm run start/yarn start.

cat -> download.sh <<'EOF'
#!/bin/sh

set -xe

for FILE in "$@"; do
  curl -sSLo "$FILE" "https://github.com/newrelic/newrelic-opentelemetry-examples/raw/refs/heads/main/getting-started-guides/javascript/$FILE"
done
EOF
sh download.sh package.json app.js instrumentation.js
yarn

Relevant Logs / Console output

Trying to start the Node.js example, I'm getting the following output:

Accessing resource attributes before async attributes settled
Accessing resource attributes before async attributes settled
Listening for requests on http://localhost:8080
{"stack":"AggregateError [ECONNREFUSED]: \n    at internalConnectMultiple (node:net:1139:18)\n    at afterConnectMultiple (node:net:1712:7)\n    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errors":"Error: connect ECONNREFUSED ::1:4318,Error: connect ECONNREFUSED 127.0.0.1:4318","code":"ECONNREFUSED","name":"AggregateError"}
{"stack":"AggregateError [ECONNREFUSED]: \n    at internalConnectMultiple (node:net:1139:18)\n    at afterConnectMultiple (node:net:1712:7)\n    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errors":"Error: connect ECONNREFUSED ::1:4318,Error: connect ECONNREFUSED 127.0.0.1:4318","code":"ECONNREFUSED","name":"AggregateError"}
{"stack":"AggregateError [ECONNREFUSED]: \n    at internalConnectMultiple (node:net:1139:18)\n    at afterConnectMultiple (node:net:1712:7)\n    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errors":"Error: connect ECONNREFUSED ::1:4318,Error: connect ECONNREFUSED 127.0.0.1:4318","code":"ECONNREFUSED","name":"AggregateError"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error AggregateError)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error AggregateError)","name":"Error"}
{"stack":"AggregateError [ECONNREFUSED]: \n    at internalConnectMultiple (node:net:1139:18)\n    at afterConnectMultiple (node:net:1712:7)\n    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errors":"Error: connect ECONNREFUSED ::1:4318,Error: connect ECONNREFUSED 127.0.0.1:4318","code":"ECONNREFUSED","name":"AggregateError"}

Nothing appears to reach the NewRelic dashboard.

I've tried updating all the packages, and replace @opentelemetry/exporter-*-otlp-proto imports to @opentelemetry/exporter-*-otlp-grpc, which produce a different output:

Accessing resource attributes before async attributes settled
Accessing resource attributes before async attributes settled
Listening for requests on http://localhost:8080
{"stack":"Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317\n    at callErrorFromStatus (~/node_modules/@grpc/grpc-js/build/src/call.js:32:19)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client.js:193:76)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:361:141)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:324:181)\n    at ~/node_modules/@grpc/grpc-js/build/src/resolving-call.js:135:78\n    at process.processTicksAndRejections (node:internal/process/task_queues:85:11)\nfor call at\n    at ServiceClientImpl.makeUnaryRequest (~/node_modules/@grpc/grpc-js/build/src/client.js:161:32)\n    at ServiceClientImpl.<anonymous> (~/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)\n    at ~/node_modules/@opentelemetry/instrumentation-grpc/build/src/clientUtils.js:131:31\n    at ~/node_modules/@opentelemetry/instrumentation-grpc/build/src/instrumentation.js:212:209\n    at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)\n    at AsyncLocalStorageContextManager.with (~/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40)\n    at ContextAPI.with (~/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)\n    at ServiceClientImpl.clientMethodTrace [as export] (~/node_modules/@opentelemetry/instrumentation-grpc/build/src/instrumentation.js:212:42)\n    at ~/node_modules/@opentelemetry/otlp-grpc-exporter-base/build/src/grpc-exporter-transport.js:100:32\n    at new Promise (<anonymous>)","message":"14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317","code":"14","details":"No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317","metadata":"[object Object]","name":"Error"}
{"stack":"Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317\n    at callErrorFromStatus (~/node_modules/@grpc/grpc-js/build/src/call.js:32:19)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client.js:193:76)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:361:141)\n    at Object.onReceiveStatus (~/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:324:181)\n    at ~/node_modules/@grpc/grpc-js/build/src/resolving-call.js:135:78\n    at process.processTicksAndRejections (node:internal/process/task_queues:85:11)\nfor call at\n    at ServiceClientImpl.makeUnaryRequest (~/node_modules/@grpc/grpc-js/build/src/client.js:161:32)\n    at ServiceClientImpl.<anonymous> (~/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)\n    at ~/node_modules/@opentelemetry/instrumentation-grpc/build/src/clientUtils.js:131:31\n    at ~/node_modules/@opentelemetry/instrumentation-grpc/build/src/instrumentation.js:212:209\n    at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)\n    at AsyncLocalStorageContextManager.with (~/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40)\n    at ContextAPI.with (~/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)\n    at ServiceClientImpl.clientMethodTrace [as export] (~/node_modules/@opentelemetry/instrumentation-grpc/build/src/instrumentation.js:212:42)\n    at ~/node_modules/@opentelemetry/otlp-grpc-exporter-base/build/src/grpc-exporter-transport.js:100:32\n    at new Promise (<anonymous>)","message":"14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317","code":"14","details":"No connection established. Last error: Error: connect ECONNREFUSED ::1:4317","metadata":"[object Object]","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: null)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: null)","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317)","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED 127.0.0.1:4317)","name":"Error"}
{"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317)\n    at PeriodicExportingMetricReader._doRun (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:88:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async PeriodicExportingMetricReader._runOnce (~/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:57:13)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established. Last error: Error: connect ECONNREFUSED ::1:4317)","name":"Error"}

Your Environment

Tried with Node.js 20.x and 22.x, same results.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions