My application is written in React and Express using Mongoose for db. I deployed a bitnami mongoDB instance in the Google Compute Engine. Now I am trying to deploy the server in the application. When I run my application locally, it connects perfectly to db (I can add stuff and see it). But when I run npm in the google cloud shell, we get this error:
'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]
Here is my connection code:
mongoose.connect(process.env.MONGODB_URI,{
useMongoClient: true
}).catch(function(err){
console.log(err)
});
MONGODB_URI=mongodb://root:password@XX.XXX.XXX.XXX:27017
,
password
- , , XX.XXX.XXX.XXX
- IP-, .
URI Google, localhost. URI, . ?