I have a remote mongodb database server that I want to connect to using the MongoClient (from mongodb package) class.
Now, the problem is I’m able to connect to the server using Robo3t but when I try to do the same with Node.js I get an error that says: MongoServerSelectionError: getaddrinfo ENOTFOUND …
A very common problem is not having the proper address in the connection string. Are you sure you are passing it? Many of the tools that you will use to connect elsewhere will have sane defaults set up, with in code you have to be very explicit : )
DO NOT SHARE your connection url.
The connection string looks ok, granted you replaced the variables. Some solutions may require you to use mongodb+srv format though. My first solution would be to go to my online db settings and copy a connection string from there - many solutions offer that.
Second try comparing your connection setting in Robot3T vs what you have in the code. Is it using an ssh tunnel perhaps?