MongoShell can connect to DB but pymongo client cannot

Hi,

After changing a network environment, I cannot access mflix DB with the code in jupyter notebook, the pymongo client show below error:
‘---------------------------------------------------------------------------’
Timeout Traceback (most recent call last)
/anaconda3/envs/mflix/lib/python3.7/site-packages/pymongo/uri_parser.py in _get_dns_srv_hosts(hostname)
286 try:
–> 287 results = resolver.query(’_mongodb._tcp.’ + hostname, ‘SRV’)
288 except Exception as exc:

/anaconda3/envs/mflix/lib/python3.7/site-packages/dns/resolver.py in query(qname, rdtype, rdclass, tcp, source, raise_on_no_answer, source_port)
1131 return get_default_resolver().query(qname, rdtype, rdclass, tcp, source,
-> 1132 raise_on_no_answer, source_port)
1133

/anaconda3/envs/mflix/lib/python3.7/site-packages/dns/resolver.py in query(self, qname, rdtype, rdclass, tcp, source, raise_on_no_answer, source_port)
948 for nameserver in nameservers[:]:
–> 949 timeout = self._compute_timeout(start)
950 port = self.nameserver_ports.get(nameserver, self.port)

/anaconda3/envs/mflix/lib/python3.7/site-packages/dns/resolver.py in _compute_timeout(self, start)
857 if duration >= self.lifetime:
–> 858 raise Timeout(timeout=duration)
859 return min(self.lifetime - duration, self.timeout)

Timeout: The DNS operation timed out after 30.00463104248047 seconds
‘---------------------------------------------------------------------------’

But I’m able to connect to my mflix DB with both pymongo and mongoshell in MAC terminal. And restarting jupyter notebook doesn’t solve it.
Does jupyter notebook have some special settings related to DNS or network?

After 30 mins I tried again with jupyter notebook and it able to connect. Seemed the network access change (open to all) have some delay for jupyter notebook to connect.

Thank you

Did you add your new IP address to your cluster white list?

Thanks for reminding. Yes I enabled access from 0.0.0.0/0. Somehow mongo shell can connect after the change, but pymongo through jupyter notebook take longer to be able to access.

Hi @XUZHENG_03440,

Please make sure your internet is working fine. Let me know if you are still not able to access.

Kanika