Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to MongoDB Atlas from Google App Engine

I'm trying to set up an API on the Google App Engine standard environment but I'm having trouble connecting to a distant MongoDB instance.

I use a free M0 cluster on MongoDB Atlas, all IP are whitelisted. The Google App Engine firewall rules allow all traffic from all IP addresses to make sure the connection request is not blocked.

However, I cannot connect to my Mongo instance and I get the following error:

ERROR db_connection querySrv ESERVFAIL <mongo-url>.gcp.mongodb.net

To connect to the MongoDB instance I use Mongoose and do the following:

const db = await mongoose.connect(uri, { useNewUrlParser: true });

However db will always be null since I cannot connect. Is there a way to connect to MongoDB Atlas from App Engine Standard or do I have to use Cloud Datastore ?

like image 778
tomrcht Avatar asked Jan 28 '23 13:01

tomrcht


1 Answers

I had to use the older version of the atlas url

enter image description here

like image 146
bj97301 Avatar answered Feb 05 '23 08:02

bj97301