adrianhajdin / threads

Develop Threads, Next.js 13 app that skyrocketed to 100 million sign-ups in less than 5 days, and dethroned giants like Twitter, ChatGPT, and TikTok to become the fastest-growing app ever!
https://threads-psi.vercel.app
1.42k stars 272 forks source link

querySrv ENOTFOUND _mongodb._tcp.cluster.3caigv3.mongodb.net #70

Open magh20 opened 10 months ago

magh20 commented 10 months ago

Error: querySrv ENOTFOUND _mongodb._tcp.cluster.3caigv3.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:251:17) at QueryReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: undefined, code: 'ENOTFOUND', syscall: 'querySrv', hostname: '_mongodb._tcp.cluster.3caigv3.mongodb.net' }

Hello, how can i fix this? I try anything and it doesn't work, Please help me.

senyahnoj commented 6 months ago

If you connect to a MongoDB database using the mongodb+srv:// connection scheme, there needs to be some custom DNS entries in existence to accompany the setup.

In you example above your DNS is cluster.3caigv3.mongodb.net and you will be connecting to it on port 27017. So you need an A record for this.

Inside the cluster, there will also need to be DNS A records for each of the replicas e.g. mongodb-0.cluster.3caigv3.mongodb.net, mongodb-1.cluster.3caigv3.mongodb.net and so on...

Finally, you need to have a DNS SRV record for _mongodb._tcp.cluster.3caigv3.mongodb.net which lists all of the replicas and ports where MongoDB can be found.

So in summary: you connect via the mongodb+srv scheme and then it instructs you to lookup the SRV record in DNS for _mongodb._tcp.cluster.3caigv3.mongodb.net which, in turn, directs you to the pool of replicas!

Have a read of the documentation here https://www.mongodb.com/docs/manual/reference/connection-string/