mongodb connection timeout when mongodb is not in the same VM

I have my MongoDB running on a Cloud VM , and NodeJS Server running on another Azure Cloud VM. I use Mongoose in the Application for MongoDB Connect. Keep getting this timeout issue every day? Any suggestions

events.js:72
        throw er; // Unhandled 'error' event
              ^
    Error: failed to connect to [XXXXX.cloudapp.net:27017]
        at null.<anonymous> (/app/satwebnodev2/satwebnodev2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:546:74)
        at emit (events.js:106:17)
        at null.<anonymous> (/app/satwebnodev2/satwebnodev2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
        at emit (events.js:98:17)
        at Socket.<anonymous> (/app/satwebnodev2/satwebnodev2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
        at Socket.emit (events.js:95:17)
        at net.js:440:14
        at process._tickCallback (node.js:419:13)

Refer this link :- http://www.slideshare.net/VictoriaMalaya1/mongo-db-in-windows-azure

MongoDB in Windows Azure:- Drawbacks and workarounds : connection timeout for .Net driver MongoDB Client Uses .Net driver socket timeout exception Windows Azure terminates an inactive connection after roughly 4 minutes of idling MongoDB suggests: Set the max idle connection time on the driver: MongoDefaults.MaxConnectionIdleTime = TimeSpan.FromMinutes(1); My experience: Add following options to connection string: maxIdleTimeMS=60000;connectTimeoutMS=60000;socketTimeoutMS=60000 Sample of connection string: connectionString="mongodb://localhost/mydb ?maxIdleTimeMS=60000;connectTimeoutMS=60000;socketTimeoutMS=60000"