SSL handshake failed while connecting to cosmos DB for MongoDB using pymongo

Michael 31 Reputation points


I created an Azure Cosmos DB for MongoDB account in azure. I got SSL handshake failed error while connecting to it using pymongo.

This is how I connect:

from pymongo import MongoClient

client = MongoClient('mongodb://<account>:<password>@<account><account>@')


I got error:

ServerSelectionTimeoutError: SSL handshake failed: <account> timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 63fd123bc7b2500fd385cc68, topology_type: Single, servers: [<ServerDescription ('<account>', 10255) server_type: Unknown, rtt: None, error=NetworkTimeout('SSL handshake failed: <account> timed out')>]>

I have tried 3.2, 3.6, 4.0 and 4.2 version, but got same error for all of them. I'm using python 3.8 in WSL 2.0. (also tried python on windows but got same error too.) I have also verified my python is using TLS 1.2.

Can anyone please help?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,437 questions
{count} vote