0

I have google app engine F1 and my app is trying to connect to mongodb atlas free tier cluster. I tested my app locally and it works fine. But I get following error when deploying to app engine. I configured my atlas to accept all IP so I don't think it's the IP issue. But I couldn't figure out why just from the error message.

2018-12-03 04:19:03 default[20181202t224815]  "GET / HTTP/1.1" 500
2018-12-03 04:19:04 default[20181202t224815]  production
2018-12-03 04:19:04 default[20181202t224815]  (node:6) 
DeprecationWarning: current URL string parser is deprecated, and will 
be removed in a future version. To use the new parser, pass option { 
useNewUrlParser: true } to MongoClient.connect.
2018-12-03 04:19:04 default[20181202t224815]  { Error: querySrv 
ESERVFAIL _mongodb._tcp.cluster0-kzjxb.mongodb.net
2018-12-03 04:19:04 default[20181202t224815]      at 
QueryReqWrap.onresolve 
[as oncomplete] (dns.js:197:19)
2018-12-03 04:19:04 default[20181202t224815]    errno: 'ESERVFAIL',
2018-12-03 04:19:04 default[20181202t224815]    code: 'ESERVFAIL',
2018-12-03 04:19:04 default[20181202t224815]    syscall: 'querySrv',
2018-12-03 04:19:04 default[20181202t224815]    hostname: 
'_mongodb._tcp.cluster0-kzjxb.mongodb.net' }
ycshao
  • 1,768
  • 4
  • 18
  • 32
  • 1
    Try the non SRV (v3.4) MongoDB URL. See also https://stackoverflow.com/questions/51946930/connect-to-mongodb-atlas-from-google-app-engine – Wan B. Dec 03 '18 at 06:37
  • Tried it and now it's giving a different error `2018-12-04 02:40:24 default[20181203t213904] { MongoNetworkError: connection 3 to cluster0-shard-00-00-kzjxb.mongodb.net:27017 closed` – ycshao Dec 04 '18 at 02:44
  • Just resolved above error by adding IP whitelist in mongodb atlas. Thanks for the help! @WanBachtiar – ycshao Dec 04 '18 at 02:55
  • @ycshao Just curious, doesn't the IP change when the app is deployed to a different zone/region? – vijayakumarpsg587 Dec 04 '18 at 04:53
  • @Joey587 yes. Depend on whether you configures a static IP or not. If not, IP may also be different between different service restart. So I just whitelisted all IP instead of specific IP. – ycshao Dec 04 '18 at 05:18
  • Oh got it :) thank you – vijayakumarpsg587 Dec 04 '18 at 09:05
  • Details of interest on connecting are offered in the "Create an Atlas Free Tier Cluster" online [document](https://docs.mongodb.com/manual/tutorial/atlas-free-tier-setup/). – George Dec 08 '18 at 02:58

0 Answers0