Cannot connect to mongodb after deploying app in Google App Engine

I am using an instance of Bitnami mongodb deployed to the Google Compute Engine.

I can connect to the mongodb instance through MongoDB clients from my personal computer using the external IP address of the MongoDB instance.

My application is an Angular2 application with Node.js. backend The following is the connection string format used in server.js

mongoose.connect('mongodb://<username>:<password>@<External IP>:27017/<dbname>');

When I host my application on localhost, it can connect to the mongodb instance in the cloud and access the data without problems.

But when the application is deployed to Google App Engine, the application no longer connects to mongodb. Below is the error.

MongoError: failed to connect to server [<External IP>:27017] on first connect

Can anyone suggest what is the main reason.

+1
1

App Engine , Compute Engine. App Engine , Compute Engine, , . IP- IP-. IP- - Google.

, App Engine Ip, . App Engine IP- .

mongodb TCP- 27017. Compute Engine . Google Cloud console gcloud:

gcloud compute firewall-rules create allow-mongodb --allow tcp:27017

+4

Source: https://habr.com/ru/post/1686763/


All Articles