Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
PyMongo MongoClient replica set won't connect

A bit of background: I used Bitnami to spin up a 3 node Mongo cluster on Azure (1 arbiter), each mongod hosted on separate VMs. I've confirmed that the replica set exists, and that each node is able to connect to one another. I've confirmed that when I take down my primary node, the secondary node steps up. When the primary node returns, it assumes the primary position again.

My problem is that I can't connect to my MongoDB replica set using MongoClient when specifying replicaset. I would get this error:

pymongo.errors.ServerSelectionTimeoutError: ArbiterIP:27017: [WinError 10061] No connection could be made because the target machine actively refused it,PrimaryIP:27017: [WinError 10061] No connection could be made because the target machine actively refused it,SecondaryIP:27017: timed out

Using MongoClient, if I do:

connection = MongoClient('MyIP1:27017', w=2)

, it connects fine. When I do

connection = MongoClient('MyIP1:27017', w=2, replicaset="repsetname")

, that's when I get the error.

Would it be related to the fact that the arbiter node has no user info for authentication?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Taking a stab at it: if you connect with the shell and do db.isMaster(), are the hostnames you see in the config the same as the hostnames like "MyIP" that you're passing to PyMongo?

It sounds like when you pass "replicaset=", PyMongo takes the hostnames from the isMaster response and connects to those instead of MyIP, but the way your replica set is configured, that set of hostnames isn't available.

For more info on why PyMongo acts this way:

https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#clients-use-the-hostnames-listed-in-the-replica-set-config-not-the-seed-list

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda