Docker compose/nodejs: Restart required to connect after ECONNREFUSED - node.js

I have a docker-compose file. There is a mysql service and a nodejs service (Nestjs using TypeORM). Sometimes when I bring the stack up, the nestjs service tries to connect to the mysql service before it is ready, and gives me a ECONNREFUSED. I've set it up to retry connecting more or less indefinitely, but once mysql is up, it continues to give me the ECONNREFUSED error.
While it is retrying, and once mysql is up, I can connect to the mysql service using nc mysql 3306, confirming it indeed can. But for some reason I continue to get the ECONNREFUSED error. Once I restart the nodejs service it connects properly. The closest I've come to figuring out the problem is perhaps it has something to do with a Connection Pool that is created in the typeorm package. Any idea how I can deal with this?`

Related

Unable to connect ECONNREFUSED / Unable to connect ENOTFOUND mongo db vsCode

I'm trying to connect my mongodb to my vscode and when I try and connect to it using 'mongodb:// it comes up with a connection error. Can anyone help me with this please? 1
you need to try this flow to solve your issue. might be it helps you.
check mongo service is running or not.
if you mongo service is out side of your current machine than you check your IP has access to access your mongo service
check your mongo connection URL is correct.
try to connect your MongoDB using tools like MongoCompass or Robo 3t.
then try in your code for further task

Prisma won't connect to Postgres database on Digital Ocean Kubernetes

I'm trying to run an application in a kubernetes pod that connects to a managed database using Digital Ocean's services. I'm sure the connection string is correct. Running the pod locally on my desktop connects to the database just fine, but when I try to connect from my cloud managed kubernetes instance I get the error ECONNREFUESED
Has anyone ever run into something like this before? (I'm using Prisma and Node.js)
(Both the kubernetes cluster and the postgres database are on Digital Ocean)
Here are the pod logs (I turned on all the prisma logging I could)
prisma:info Starting a postgresql pool with 9 connections.
prisma:info Started http server on http://127.0.0.1:42535
PrismaClientKnownRequestError3 [PrismaClientKnownRequestError]:
Invalid `prisma.user.findUnique()` invocation:
connect ECONNREFUSED ::1:42535
at cb (/app/node_modules/#prisma/client/runtime/index.js:36494:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async login (/app/src/gql/Users/resolvers.ts:267:16) {
code: 'ECONNREFUSED',
clientVersion: '2.30.3',
meta: undefined
So, that's what happens when I try to run the "login" mutation, just for an example. Prisma tries to find the user but - it can't connect - and this is the resulting error message.
Again, it's absolutely fine when I run locally in a kubernets pod on my local machine (using docker desktop). I'm sure the user/pass/port is fine because I connect fine with pgAdmin. I'm sure the connection string is correct because it works fine in my local cluster. I'm looking for something - anything - to give a clue why I can't connect from Digital Ocean! I have also tried other database providers with the same result. Error message is always the same, only thing that changes is teh port on the prisma http server. (this is desperation haha). Does anyone have any insight to what could be going on?? What could be different that allows me to connect from docker desktop's kubernetes but prevents it on Digital Ocean's cluster?
Found the "solution". Upgraded to prisma v3.
If you can't do that, there's more info here: https://github.com/prisma/prisma/issues/9899

MongoDB stopped working suddenly after days of development

After a few days of developing using Nodejs and MongoDB today I'm getting this error when I want to get into the first page of my app:
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
And when I try to connect to db using mongodb compass:
Have you verified if mongo is running in the background?
Run mongod in the terminal and see the response, maybe your mongo process is'nt running and then you cant connect to your local mongodb.
I had the same issue and I fixed it.
Go to Services -> search for "MongoDB Server".
Right Click on it and then Click on Start.

Heroku redis remote connection

I have had the redis instance working for some time but now i'm trying to connect to my Redis addon and i'm getting a timeout error while connecting.
My app is made with nodejs, using redis module and i have already tried with process.env.REDIS_URL and with the full url and it's not connecting
Anyone knows if Heroku addons allow remote connection? even with redis -h URL is not working

connect ECONNREFUSED 127.0.0.1 in node.js

so I make a server in nodejs to connect with mongodb, from the start I use it until tomorrow is working fine, but today when I use it there is this error
this error appear when user want log in in my application.

Resources