Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17129

SSL handshake failed error when trying to connect to MongoDB with Python client

$
0
0

I'm trying to connect to my shared MongoDB cluster, but I keep receiving the following error: SSL handshake failed: ac-ascvkib-shard-00-02.hkzvmvh.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host.

The exact code I'm using is below:

from pymongo.mongo_client import MongoClient# I replaced <password> with my own passworduri = "mongodb+srv://admin:<password>@cluster0.hkzvmvh.mongodb.net/?retryWrites=true&w=majority"# Create a new client and connect to the serverclient = MongoClient(uri)# Send a ping to confirm a successful connectiontry:    client.admin.command('ping')    print("Pinged your deployment. You successfully connected to MongoDB!")except Exception as e:    print(e)

I'm using Python 3.11 and I'm using pymongo==3.11. I'm on a windows machine, and it seems that the error message gets printed multiple times.


Viewing all articles
Browse latest Browse all 17129

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>