我可以连接到部署在应用程序引擎上的从本地主机部署mongoDB的谷歌云,但不能从同一个应用程序

我的应用程序是使用Mongoose为数据库编写的React和Express。 我在Google计算引擎上部署了一个bitnami mongoDB实例。 现在我试图在App引擎上部署服务器。 当我在本地运行我的应用程序,它可以很好地连接到数据库(我可以添加的东西,看看它)。 但是,当我做一个npm开始在谷歌云壳得到这个错误:

'failed to connect to server [35.196.182.249:27017] on first connect [MongoError: connection 0 to 35.196.182.249:27017 timed out]' } (node:1310) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [35.196.182.249:27017] on first connect [MongoError: connection 0 to 35.196.182.249:27017 timed out] 

这是我的代码连接:

 mongoose.connect(process.env.MONGODB_URI,{ useMongoClient: true }).catch(function(err){ console.log(err) }); 

其中MONGODB_URI=mongodb://root:password@XX.XXX.XXX.XXX:27017password是我从计算引擎获得的密码,而XX.XXX.XXX.XXX是计算引擎提供的外部IP。 当本地连接和谷歌云壳连接时,我使用相同的URI,但只连接本地主机。 我也试图在URI中硬编码,并没有工作。 有任何想法吗?