MongoDB remote access

HI I am using the node node-red-node-mongodb in order to do a remote connection to mongoDB and this error is display "MongoError: connection 507 to pruebanodered-shard-00-00-mtmwd.mongodb.net:27017 closed".
I already do the port test and the port is available and I also check the hostname and I am sure it is correct. Also I configure access in MongoAtlas in order to allow acces from anywhere and it still doesn't work. I have no idea what else I could do

Are the username and password double-checked? I’ve a setup like that on Atlas too (hate the access from everywhere part but with code running on the free heroku tier I can’t configure addresses sadly enough), though I don’t connect through NR. I might set it up like that tomorrow morning with that node to see if I can reproduce it.

Yes I have check username and password, I am sure they are correct. I don't understand why this error is happening

@ljavih just reproduced it from my Atlas setup. I think I know what it is caused by, going to see if I can debug it.

It's caused by the following block of code:


Newer versions of mongodb use the authdb to authorise against to the server, then switch to the database they interact on. This is handled through setting a parameter behind that url, authSource=<authdb>.
The contrib node node-red-contrib-mongodb3 actually solves this issue, switching to that node should do the trick.

Considering the node-red-node-mongodb describes itself as "connecting to a local mongodb database", I'm not sure if this would be considered a bug since this is something that mostly happens at hosted installs, though it will probably happen on home/local installs too if you follow the documentation on securing your install (which you should, as insecure mongodb installs are a honeypot for hackers). @dceejay

1 Like

looking forwards to your first PR to fix it :slight_smile: ... thanks!

1 Like

Something to add to my already long to-do list :stuck_out_tongue:

I also use this node and I am able to insert data in MongoDB, but I am unable to extract data from the DB using this node. If you have any idea of how I could do this will be really helpful. Thanks for your help

I get a "failed to connect to server [xxx-shard-00-01-aq7ik.mongodb.net:27017] on first connect" although I am positive that all the data entered is correct. Any help why this might be?

I see in your address .mongodb.net, which I think includes Atlas cloud database. Have you checked in the settings which ip addresses are allowed to access the database remotely?