Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All nameservers failed to answer UDP port 53 Google cloud functions python 3.7 atlas mongodb

i can connect locally to my mongodb server with the address 0.0.0.0/0. However, when I deploy my code to the cloud I get the error deploy to google cloud function.

google cloud function with python 3.7 (beta) atlas mongo db python lib: -pymongo -dnspython

Error: function crashed. Details: All nameservers failed to answer the query _mongodb._tcp.**-***.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53 answered SERVFAIL

Traceback (most recent call last): File "/env/local/lib/python3.7/site-packages/pymongo/uri_parser.py", line 287, in _get_dns_srv_hosts results = resolver.query('_mongodb._tcp.' + hostname, 'SRV') File "/env/local/lib/python3.7/site-packages/dns/resolver.py", line 1132, in query raise_on_no_answer, source_port) File "/env/local/lib/python3.7/site-packages/dns/resolver.py", line 947, in query raise NoNameservers(request=request, errors=errors) dns.resolver.NoNameservers: All nameservers failed to answer the query _mongodb._tcp.**mymongodb**-r091o.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53

like image 838
Satria Bondan Saputra Avatar asked Sep 20 '25 05:09

Satria Bondan Saputra


1 Answers

finally after stuck 2 day, goblok banget semaleman

just change connection from

SRV connection string (3.6+ driver)

to

Standard connection string (3.4+ driver)

mongodb://<USERNAME>:<PASSWORD>@<DATABASE>-shard-00-00-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-01-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-02-r091o.gcp.mongodb.net:27017/test?ssl=true&replicaSet=<COLLECTION>-shard-0&authSource=admin&retryWrites=true

or you can see your connection string in atlas mongodb.

idk why can`t connect with srv connection string in google cloud functions, maybe not suppot now, or just misconfiguration.

like image 157
Satria Bondan Saputra Avatar answered Sep 21 '25 18:09

Satria Bondan Saputra