I am using axios as an HTTP client. When I try to POST on my local server I get this error message:
{ Error: connect ECONNREFUSED 127.0.0.1:80
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 80,
config:{......................
.............................
.........}
I don't know what is wrong in my node js app. I am posting data to port 80(instead of to localhost' port) Does someone have any ideas?
Related
This is on theRailway console:
original: Error: getaddrinfo ENOTFOUND undefined
original: Error: getaddrinfo ENOTFOUND undefined
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
errno: -3008,
errno: -3008,
code: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
syscall: 'getaddrinfo',
hostname: 'undefined'
hostname: 'undefined'
I follow all the steps to deploy my full-stack app on railway. I first, deployed my db from postgress successfully and pass it the links to my .env on my server side app. Now, looks like the hostname is not working not sure why is this happening.
When I try to run the hosted API app, I get the following message:
2022-04-11T12:32:31: Server running at http://localhost:9000
2022-04-11T12:32:31: Error: getaddrinfo ENOTFOUND localhostss
2022-04-11T12:32:31: at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
2022-04-11T12:32:31: errno: -3008,
2022-04-11T12:32:31: code: 'ENOTFOUND',
2022-04-11T12:32:31: syscall: 'getaddrinfo',
2022-04-11T12:32:31: hostname: 'localhostss',
2022-04-11T12:32:31: fatal: true
2022-04-11T12:32:31: }
Please help me fix
index.js:
enter image description here
hostname is wrong
according to error hostname is localhostss rather than localhost
I am trying to connect the node js container with the Redis container, I am facing an issue when I run the node-js container and try to connect Redis. I tried most of the solutions from the web, still not able to fix the connection refused issuer.
> Node js creating the Redis client: below code works locally good, without the container.
const redis = require('redis')
const redisClient = redis.createClient({
host: "127.0.0.1",
port: "6379"
})
> running Redis from the latest image.
docker run -d --name redis -p 6379:6379 redis
> Error:
[nodemon] starting `node index.js`
events.js:377
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
Emitted 'error' event on RedisClient instance at:
at RedisClient.on_error (/usr/src/app/node_modules/redis/index.js:342:14)
at Socket.<anonymous> (/usr/src/app/node_modules/redis/index.js:223:14)
at Socket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379
}
I have node.js app that uses Redis as a cache among other things.
When my app is running on my Linux server it works great without any problems. But when I am running it locally on my windows machine through WSL it disconnects randomly but mostly when it idles.
it disconnects with this error:
Emitted 'error' event on RedisClient instance at:
at RedisClient.on_info_cmd (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:431:14)
at C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:470:14
at Object.callbackOrEmit [as callback_or_emit] (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\lib\utils.js:89:9)
at Command.callback (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\lib\individualCommands.js:157:15)
at RedisClient.flush_and_error (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:309:29)
at RedisClient.connection_gone (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:602:14)
[... lines matching original stack trace ...]
at endReadableNT (node:internal/streams/readable:1307:12) {
code: 'UNCERTAIN_STATE',
command
}
And on rarer times with this error:
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
Emitted 'error' event on RedisClient instance at:
at RedisClient.on_error (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:341:14)
at Socket.<anonymous> (C:\Users\mynam\OneDrive\Desktop\nodeapp\node_modules\redis\index.js:222:14)
at Socket.emit (node:events:379:20)
at emitErrorNT (node:internal/streams/destroy:188:8)
at emitErrorCloseNT (node:internal/streams/destroy:153:3)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379
}
I'm doing a stress test to my nodejs app, the test basically send a bulk of requests concurrently, sometimes I got this annoying error:
{ RequestError: Error: connect ECONNREFUSED 127.0.0.1:1234
at new RequestError (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request.onRequestError (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:198:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'RequestError',
message: 'Error: connect ECONNREFUSED 127.0.0.1:1234',
cause:
{ Error: connect ECONNREFUSED 127.0.0.1:1234
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 1234 }
So the test keeps returning this error for "almost" all the requests, but I still can send requests via postman without any problem.
Can anyone explain me what is the problem here ? and how it can be solved ? like using a queue a proxy or anything else useful ?
Thanks in advance