pymongo unable to connect to primary
<p>I'm trying to <code>find_one</code> by connecting to my replica set's primary node.</p>

<pre><code>MongoClient(hostname, replicaSet="rs0", read_preference=ReadPreference.PRIMARY)
</code></pre>

<p>But it results in an error:</p>

<blockquote>
  <p>ServerSelectionTimeoutError: No replica set members match selector
  "Primary()"</p>
</blockquote>

<p>I'm able to successfully read using <code>SECONDARY_PREFERRED</code>. I also tried connecting using <code>MongoReplicaSetClient</code> with no success. I'm guessing this due to bad configuration, but what should I be looking for?</p>

<p>rs.status:</p>

<pre><code>rs0:PRIMARY&gt; rs.conf()
{
       "_id" : "rs0",
       "version" : 111313,
       "protocolVersion" : NumberLong(1),
       "members" : [
               {
                       "_id" : 1,
                       "host" : "ANDROMEDA:27017",
                       "arbiterOnly" : false,
                       "buildIndexes" : true,
                       "hidden" : false,
                       "priority" : 1,
                       "tags" : {

                       },
                       "slaveDelay" : NumberLong(0),
                       "votes" : 1
               },
               {
                       "_id" : 2,
                       "host" : "mongo02.db.com:27017",
                       "arbiterOnly" : false,
                       "buildIndexes" : true,
                       "hidden" : false,
                       "priority" : 0.5,
                       "tags" : {

                       },
                       "slaveDelay" : NumberLong(0),
                       "votes" : 1
               },
               {
                       "_id" : 3,
                       "host" : "mongo03.db.com:27017",
                       "arbiterOnly" : false,
                       "buildIndexes" : true,
                       "hidden" : false,
                       "priority" : 0.5,
                       "tags" : {

                       },
                       "slaveDelay" : NumberLong(0),
                       "votes" : 1
               }
       ],
       "settings" : {
               "chainingAllowed" : true,
               "heartbeatIntervalMillis" : 2000,
               "heartbeatTimeoutSecs" : 10,
               "electionTimeoutMillis" : 10000,
               "getLastErrorModes" : {

               },
               "getLastErrorDefaults" : {
                       "w" : 1,
                       "wtimeout" : 0
               }
       }
}
rs0:SECONDARY&gt; rs.status()
{
       "set" : "rs0",
       "date" : ISODate("2016-08-04T08:58:02.293Z"),
       "myState" : 2,
       "term" : NumberLong(90),
       "syncingTo" : "mongo03.db.com:27017",
       "heartbeatIntervalMillis" : NumberLong(2000),
       "members" : [
               {
                       "_id" : 1,
                       "name" : "ANDROMEDA:27017",
                       "health" : 1,
                       "state" : 1,
                       "stateStr" : "PRIMARY",
                       "uptime" : 2503,
                       "optime" : {
                               "ts" : Timestamp(1470299746, 1),
                               "t" : NumberLong(90)
                       },
                       "optimeDate" : ISODate("2016-08-04T08:35:46Z"),
                       "lastHeartbeat" : ISODate("2016-08-04T08:58:01.109Z"),
                       "lastHeartbeatRecv" : ISODate("2016-08-04T08:58:01.803Z"),
                       "pingMs" : NumberLong(28),
                       "electionTime" : Timestamp(1469600522, 1),
                       "electionDate" : ISODate("2016-07-27T06:22:02Z"),
                       "configVersion" : 111313
               },
               {
                       "_id" : 2,
                       "name" : "mongo02.db.com:27017",
                       "health" : 1,
                       "state" : 2,
                       "stateStr" : "SECONDARY",
                       "uptime" : 7604104,
                       "optime" : {
                               "ts" : Timestamp(1470299746, 1),
                               "t" : NumberLong(90)
                       },
                       "optimeDate" : ISODate("2016-08-04T08:35:46Z"),
                       "syncingTo" : "mongo03.db.com:27017",
                       "configVersion" : 111313,
                       "self" : true
               },
               {
                       "_id" : 3,
                       "name" : "mongo03.db.com:27017",
                       "health" : 1,
                       "state" : 2,
                       "stateStr" : "SECONDARY",
                       "uptime" : 2503,
                       "optime" : {
                               "ts" : Timestamp(1470299746, 1),
                               "t" : NumberLong(90)
                       },
                       "optimeDate" : ISODate("2016-08-04T08:35:46Z"),
                       "lastHeartbeat" : ISODate("2016-08-04T08:58:01.948Z"),
                       "lastHeartbeatRecv" : ISODate("2016-08-04T08:58:01.802Z"),
                       "pingMs" : NumberLong(28),
                       "syncingTo" : "ANDROMEDA:27017",
                       "configVersion" : 111313
               }
       ],
       "ok" : 1
}
</code></pre>