MongoError: not master

796 views
Skip to first unread message

Nikhil Jain

unread,
May 19, 2016, 12:18:10 PM5/19/16
to mongodb-user
Hi,

I am trying to connect node.js app to MongoDB having replica set but its throwing an error when any write operations are performed.

It throws MongoError: not master. 

It tries to write on secondary mongo instances.

I have the options as  { db: { readPreference: secondaryPreferred } } and passing it to the function MongoClient.connect

The URL used to connect looks like mongodb://admin:pass@host_one:27017,host_two:27017,host_three:27017/dbName

Any help would be really appreciated.



~ Nikhil



Nikhil Jain

unread,
May 23, 2016, 10:12:01 AM5/23/16
to mongodb-user
 I did som debugging and it seems like its throwing an error while executing the drop collection call. The other commands seems to run fine.

Kevin Adistambha

unread,
May 24, 2016, 2:21:05 AM5/24/16
to mongodb-user

Hi Nikhil,

I did som debugging and it seems like its throwing an error while executing the drop collection call. The other commands seems to run fine.

I have confirmed that when using secondaryPreferred read preference, dropping a collection using the current node.js driver version 2.1.19 resulted in a not master error, which does not happen with other commands such as insert, update, and delete.

I noticed that you have submitted a JIRA ticket NODE-716. The ticket was recently resolved, and the fix will be included in the next release of the node.js driver.

Thank you for reporting this issue.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages