Error connecting to mongodb

when i configure a mongo node
it shows the error as

"MongoError: failed to connect to server [127.0.0.1:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]"

I cannot connect to MongoDB to store the tweets.
Help me with this.
Thank you.

please don’t flag the same issue in multiple threads.

There are many reasons for that error. Most are not to do with Node-RED but with your mongobd database.

These include mongodb is not running, it crashed and has a lock file you need to delete, the port is busy.

There is not any issue with my mongo database as im using it with live applications, this occurs only with the node-red docker image, when i run locally it is working properly, so there is something missing with the docker image.

I was thinking this forum could help with some valuable and serious ideas. Not just to recommend google it.

Thanks any way.

Is your mongo server allowing incoming traffic through (outgoing) docker containers? Say you were to get a shell into your running docker container, then call it manually. Does it run? If yes it might be a node-red issue. If no it might be a docker/mongo issue.

You never mentioned docker in your original post so how are we to guess ? but yes - unless you have specifically opened up the necessary ports for mongo on your docker instance then the Node-RED mongo node won't be able to get out to make a connection.

1 Like

Thank you very much for sugest such a test, I will do.

You right, I should have mentioned that I were running node-red on a docker image, I will validate if the ports are opened. Thansk so much for answer.