microlinkhq / keyvhq

Simple key-value storage with support for multiple backends.

Home Page:https://keyvhq.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

querySrv ENOTFOUND when using Mongo v4.0 connection strings

thaddeuskkr opened this issue · comments

Hi, when using a connection string for MongoDB v4.0 and up (not stated in docs for this package, but your index.js file seems to have parsing new URLs enabled so I assumed it would work?), I get the following error:

Error: querySrv ENOTFOUND _mongodb._tcp.thad.93xhb.mongodb.net                         
^[[90m    at QueryReqWrap.onresolve [as oncomplete] (node:dns:213:19)^[[39m {          
  errno: ^[[90mundefined^[[39m,                                                        
  code: ^[[32m'ENOTFOUND'^[[39m,                                                       
  syscall: ^[[32m'querySrv'^[[39m,                                                     
  hostname: ^[[32m'_mongodb._tcp.thad.93xhb.mongodb.net'^[[39m                         
}

Connection string:
mongodb+srv://tkkr:<password>@thad.93xhb.mongodb.net/<dbName>?retryWrites=true&w=majority

I've ensured that the password is correct.
Are the new connection URLs just not supported?

mongodb+srv urls refer to mongodb cluster urls and they are supported, does it connect normally when directly using the MongoClient?

const { MongoClient } = require('mongodb')

const URL = ...
const client = new MongoClient(URL)
client.connect().then(() => console.log(client))

mongodb+srv urls refer to mongodb cluster urls and they are supported, does it connect normally when directly using the MongoClient?

const { MongoClient } = require('mongodb')

const URL = ...
const client = new MongoClient(URL)
client.connect().then(() => console.log(client))

Weirdly, no. The same error occurs. What does this mean?

dns errors or some internet error, the url seems to be correct.

yea but the thing is I've whitelisted the IP in mongodb atlas, any other steps you think i should take to try to fix this?

I think its an issue with your dns, maybe try a different one,
or goto the atlas dash and choose the older uri string with mongo:// instead of +srv one,
you should also consider allowing access from anywhere in atlas

Since this issue is out of the scope of this package/repo I would recommend going to stack overflow or atlas forums to receive better support