not master and slaveOk=false, Code: 13435 connection error

Issue:

This error is displayed when you've connected to a standalone host:

Server returned not master error.
Message: not master and slaveOk=false
Code: 13435
Not master error

And your MongoDB connection looks like this:
Not master error connection

Reason:

This error means you are trying to read from a secondary replica set member. But the secondary member (the Slave) is not setup to perform reads.

How to fix:

There are three ways how to solve this issue. But we recommend the first way.

1. Use Replica Set connection mode

Edit your connection, specify 'Replica Set' in 'Connect to' field and add your host as single replica set member. Also you can add other replica set members to this connection.
Not master error specify Replica Set mode

2. Connect to a primary replica set memeber.

You need to discover the primary replica set member. You can ask your database administrator, hosting or cloud provider, find it with NoSQL Manager for MongoDB or with rs.status() command.
Discover primary replica set member

rs.status()

Discover primary replica set with rs.status()

In this sample the primary node is mongodb1:27341.
Now update your connection:
Not master error use primary replica set member
Please note: primary node can be changed during replica set election process, in this case the error can occur again.

3. Use rs.slaveOk()

Allow this node to accept reads by running rs.slaveOk() in a mongo shell (connected to the node), but it isn't recommended.