You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python连接MongoDB Atlas时出现SSL握手失败问题求助

MongoDB Atlas SSL握手失败排查与解决求助

我正在使用pymongo库连接MongoDB Atlas,代码如下。已经做了以下排查但问题仍未解决:

  • 更换过不同网络环境(家用WiFi、手机热点等),排除基础网络限制
  • 确认Atlas集群处于正常运行状态,无影响连接的维护操作
  • 将pymongo、certifi等相关依赖库更新至最新版本

连接代码

from pymongo import MongoClient, server_api
import certifi

# MongoDB Atlas connection URI
uri = 'mongodb+srv://<username>:<password>@<cluster-address>/?retryWrites=true&w=majority&appName=TaipeiYouBikeHourlyData'

# Use the certifi library to get the path of the CA certificate
ca = certifi.where()

try:
    # Create a MongoClient instance and specify the CA certificate path
    client = MongoClient(uri, server_api=server_api.ServerApi('1'), tlsCAFile=ca)
    
    # Send a ping command to test the connection
    response = client.admin.command('ping')
    print("Successfully connected to MongoDB, response:", response)

except Exception as e:
    print("Error connecting to MongoDB:", e)

有没有人遇到过类似的MongoDB Atlas SSL握手失败问题?求具体的解决方法,以及我可能遗漏的排查步骤或配置建议?

内容的提问来源于stack exchange,提问作者hongyue

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 15:06:02