pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed

pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: my-clus1-shard-00-00-pri.xyz.mongodb.net:27017: [SSL: WRONG_VERSION_NUMBER]

Flask==2.0.2
Flask-PyMongo==2.2.0
requests==2.20.1
pymongo[tls,srv]==4.0.1

Any idea why the wrong ssl is from the packages or something else

What operating system, Python version and MongoDB version, and are you trying to connect through a proxy?

Docker
FROM python:3.6.8-alpine3.9

WORKDIR /app

COPY requirements.txt .

RUN pip install -r requirements.txt

RUN pip install gunicorn

COPY flaskr/bar.py .

EXPOSE 5000

CMD [“python”, “bar.py”]

What version of MongoDB and where is MongoDB running?

I found that the ssl issue is a red herring , i was trying to connect to a db in a different region and the error presented as such.

Its very strange and dishearting none the less everything is working now

how did you fixed it?, i have the same error

It may be due to the OpenSSL updates. If you are on ubuntu:22.04, upgrade to ubuntu:23.x. However what OS are you on right now and the mongodb version now?

Hi, check your network access configuration in Atlas in case you are connecting to it.

In my case, I was connecting to an instance in Atlas. As long as I have added the new IP, I was using from my network, I could connect

1 Like

YES!!! I encountered the same error and after 2 hours of troubleshooting this is what solved my issue. Just add your IP to the cluster

1 Like