Connection to mongo (on often timeout

My db connection has been timing out often recently. I’m getting logs like:

MongoError: connection 10 to<myDBPort> timed out
    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:449:15)
    at SynchronousCursor._nextObject (packages/mongo/mongo_driver.js:1021:47)

    at SynchronousCursor.forEach (packages/mongo/mongo_driver.js:1055:22)
    at Cursor.(anonymous function) [as forEach] (packages/mongo/mongo_driver.js:904:44)
    at createNotification (src/server/lib/notifications.js:308:84)

Where should I look at? What is Meteor’s mongo timeout?

1 Like

The same thing happens to me, today the whole website went down and checking the logs found this error. Did you solve this? did you find out what is going on?

1 Like

Hi, yes I solved it. It was not a Meteor issue but a bad indexing on my mongo db that was doing some entire collection scanning on very large collections. This was occasionally causing the query to fail and other connections to drop. Ffxsam shared a link on mongo indexing that helped me quite a bit in this message: Collection._ensureIndex creating several indexes?

I’d first look at your mongo logs and look for some COLLSCAN. Mine looked like

planSummary: COLLSCAN keysExamined:0 docsExamined:<a lot of them>

If you’re hosted on, they have a good metric dashboard that will give you a sense of your memory issues.