Chapter 1: Lab - $match

Hey guys,

No issues running find() on movies collection, however, keep getting this error when trying to run aggregate function:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.aggregate([{"$match": { “genres”: { $nin: [“Crime”,“Horror”]} }}])
2019-01-19T14:41:34.785+1100 E QUERY [js] Error: error doing query: failed: network error while attempting to run command ‘aggregate’ on host ‘’ :
2019-01-19T14:41:34.786+1100 I NETWORK [js] Marking host as failed :: caused by :: Location40657: Last known master host cannot be reached

Has anyone come across this previously?


This error may happen when I didn’t send any query or anything to the host in a long time . It seems like the host close the connection for efficiency . And it will reconnect immediately then, after reporting the error.

with below , i am getting 9 records. should get 23

db.movies.aggregate( < deleted >

Please follow forum guidelines and do not post code that are potential answers.

The following link will help you.


Please follow Forum guidelines and do not post code or answers – correct or otherwise – here. I have edited your post accordingly.

Also notice that you are attaching a new question to an old thread. I would strongly recommend that you start a new post for a new question.