connect ECONNREFUSED 127.0.0.1 in node.js - 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.

Related

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.

Mongo Compass Can't Connect to my Server. NodeJS and shell works

I have a MongoDb server setup on my server.
When i start my nodeJs application on it it works perfectly, i can also view and edit my db using the shell when im connected via ssh.
It also used to work with mongo Compass, then a few days suddenly i couldn't connect to my db using compass anymore. Shell and nodeJs connections are still working tho.
I Am getting The Error connect ECONNREFUSED 127.0.0.1:27017
After a Bit looking around an i read a article stating i should look at the log at /var/log/mongodb/mongobd.log
This is The Output from The log, when im trying to connect via ssh. I've already confirmed that this entry is mongo compass trying to connect by restarting and shutting down every service which is using mongodb.
2020-05-03T21:26:19.575+0000 I NETWORK [listener] connection accepted from 127.0.0.1:33694 #5 (3 connections now open)
2020-05-03T21:26:49.689+0000 I NETWORK [conn5] end connection 127.0.0.1:33694 (2 connections now open)

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

Docker compose/nodejs: Restart required to connect after ECONNREFUSED

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?`

Connecting to a mongoDB with a TCP prefix on a NodeJS application

I created a NodeJS app that connects with a MongoDB and it seems to work locally.
Now, after hosting the NodeJS application on a remote machine, I am trying to connect to a mongoDB that was already created on that machine. When I print out some of the environment variables, the only one I see of relevance seems to be :
MONGODB_PORT: 'tcp://172.30.204.90:27017',
I tried connecting like I usually do with
mongoose.connect('mongodb://localhost:27017/metadata/')
and replacing it with mongoose.connect('tcp://172.30.204.90:27017/metadata') but I get an error that says my URI needs to start with 'mongodb'.
So I tried replacing it with mongoose.connect('mongodb://172.30.204.90:27017/metadata') and it no longer throws any error. But on the MongoDB side I don't see any new connections happening and my app does not start up on the machine. What should I be putting in the URI?
Your URI should indeed start with mongodb:
mongoose.connect('mongodb://username:password#host:port/database?options...');
See this page for more information: https://docs.mongodb.com/manual/reference/connection-string/
Did you try to connect to the database from cli? Or Telnet to see that connection isn't blocked.

Resources