Not Able to connect To MongoDB Atlas

error: Error: querySrv EREFUSED _mongodb._tcp.cluster0.xlbe3.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:47:19)

I am Getting this error even though my string is correct and i get this error mutliple times i think there is something wrong with my PC

Good afternoon, welcome to the MongoDB community.

Have you allowed access to your project’s Access List to connect to your cluster?

yup

0.0.0.0/0

i use this one to have access from anywhere

sometimes it get connected to it but once i restart my project it shows above error this happens multiple times with me

Good morning!

What would “restart the project” mean? I’m not sure I understand this terminology.

Are you trying to access from your desktop? Is your computer’s IP not changing? Isn’t there a firewall in between that could be preventing the connection?

i am running my project in my desktop using vsCode.
Restart means whenever i restart my computer and run my project again.
Yes i do have firewall in my computer i use windows 11

i used to off the firewall then restart my project it get connected to mongoDB but now this hack is also not working

I just want to know thw cause of this error

Thanks for the answer. This behavior is strange. If you have 0.0.0./0 it shouldn’t be a problem in Atlas.

Can you do some tests like ping and telnet to help with the resolution?

Also, if you could tell me the error you get when trying to connect.

1 Like

I am doing this way trying to connect to cluster and i am getting this

ping cluster0.xxxxxxx.mongodb.net
Ping request could not find host cluster0.b1p7eko.mongodb.net. Please check the name and try again.

You are unable to resolve the cluster’s DNS. You don’t even get to Atlas. It is possibly a problem with your computer’s resolution. When you disable the firewall does it still not work?

You cannot ping a cluster because it is not an host with an IP address.

What you may do is ping the hosts of your replica set. You may get the list of hosts of your replica set directly in Atlas. DNS for a cluster has 2 types of records. A TXT record and SRV records. For your cluster we get

id 54082
opcode QUERY
rcode NOERROR
flags QR RD RA
;QUESTION
cluster0.b1p7eko.mongodb.net. IN ANY
;ANSWER
cluster0.b1p7eko.mongodb.net. 60 IN TXT "authSource=admin&replicaSet=atlas-cyxfww-shard-0"
cluster0.b1p7eko.mongodb.net. 60 IN SRV 0 0 27017 ac-uk99ezp-shard-00-00.b1p7eko.mongodb.net.
cluster0.b1p7eko.mongodb.net. 60 IN SRV 0 0 27017 ac-uk99ezp-shard-00-01.b1p7eko.mongodb.net.
cluster0.b1p7eko.mongodb.net. 60 IN SRV 0 0 27017 ac-uk99ezp-shard-00-02.b1p7eko.mongodb.net.
;AUTHORITY
;ADDITIONAL

The ac-*-b1p7eko.mongodb.net are the 3 hosts of your cluster.

2 Likes