I try to run a node/express app on ec2 using a docker image with this command "sudo docker run -it -p 127.0.0.1:3000:3000 name/app:latest"
and I receive the following error:
UnknownEndpoint: Inaccessible host: `logs.us-east-1.amazonaws.com’ at port `undefined’. This service may not be available in the `us-east-1' region.
at Request.ENOTFOUND_ERROR (/usr/app/node_modules/aws-sdk/lib/event_listeners.js:574:46)
at Request.callListeners (/usr/app/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/app/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/app/node_modules/aws-sdk/lib/request.js:686:14)
at error (/usr/app/node_modules/aws-sdk/lib/event_listeners.js:406:22)
at ClientRequest.<anonymous> (/usr/app/node_modules/aws-sdk/lib/http/node.js:99:9)
at ClientRequest.emit (node:events:527:28)
at ClientRequest.emit (node:domain:475:12)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
Emitted ‘error’ event on DerivedLogger instance at:
at DerivedLogger.transportEvent (/usr/app/node_modules/winston/lib/winston/logger.js:639:12)
at CloudWatchTransport.emit (node:events:539:35)
at CloudWatchTransport.emit (node:domain:475:12)
at Relay.<anonymous> (/usr/app/node_modules/winston-aws-cloudwatch/lib/index.js:15:41)
at Relay.emit (node:events:527:28)
at Relay.emit (node:domain:475:12)
at Relay._onError (/usr/app/node_modules/winston-aws-cloudwatch/lib/relay.js:74:12)
at /usr/app/node_modules/winston-aws-cloudwatch/lib/relay.js:53:57
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: ‘UnknownEndpoint’,
region: ‘us-east-1’,
hostname: ‘logs.us-east-1.amazonaws.com’,
retryable: true,
originalError: Error: getaddrinfo EAI_AGAIN logs.us-east-1.amazonaws.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
errno: -3001,
code: ‘NetworkingError’,
syscall: ‘getaddrinfo’,
hostname: ‘logs.us-east-1.amazonaws.com’,
region: ‘us-east-1’,
retryable: true,
time: 2022-11-17T15:06:46.985Z
},
time: 2022-11-17T15:06:46.985Z
}
AWS AMI: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20220912
"@aws-sdk/client-cloudwatch-logs": "^3.183.0", HTTPS is enabled on server
If I clone the repo on ec2 and run it using "pm2 --name appName start npm -- start
" it works well.
Can you help me to understand how to fix this problem?
CodePudding user response:
I fixed this problem by using the docker host network with the following flag docker --network host
as described here.