Unable to connect to hidden secondary


i have replica set with 3 secondary in one VPC1 and 4-th secondary hidden member in another VPC2 in subnet1. There is a peering connection between vpc`s (only for vpc2 subnet1)
Connection to hidden from VPC2 subnet1 establish fine.

But if i try connection from vpc2 subnet2 to hidden member (for vpc2 subnet2 visible only vpc2 subnet1) catch error:

 File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/topology.py", line 201, in select_servers
    selector, server_timeout, address)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/topology.py", line 218, in _select_servers_loop
    (self._error_message(selector), timeout, self.description))
pymongo.errors.ServerSelectionTimeoutError: No replica set members match selector "Primary()", Timeout: 3.0s, Topology Description: <TopologyDescription id: 6205bf04e1315e98211bed68, topology_type: ReplicaSetNoPrimary, servers: [

try connection strings:


is it capable connect to hidden if primary is invisible for client?

Welcome to the MongoDB Community Forums @Georgiy!

Clients will not distribute queries to hidden secondaries using read preferences: you need to use a direct (or “standalone”) connection to the hidden secondary.

A direct connection string will not include the replicaSet or readPreference options, and the client will not perform discovery or failover based on the current replica set configuration. PyMongo 3.11+ additionally requires the directConnection option to be True.

Assuming is the hidden secondary, try the following connection string in PyMongo:



1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.