Skip to main content
 首页 » 编程设计

mongodb之使用 Azure Cosmos DB for MongoDB API 连接错误的 Flask 应用程序

2025年05月04日88bluestorm

我正在使用 Azure Cosmos DB for MongoDB API 构建 Flask 应用程序,但在以下几行中遇到连接错误。我正在关注这个:https://github.com/Azure-Samples/CosmosDB-Flask-Mongo-Sample

我在以下行中收到错误:

client = MongoClient("mongodb://127.0.0.1:10250/?ssl=true")  

当我运行 Flask 服务器时,出现以下错误: pymongo.errors.ConnectionFailure: [WinError 10061] 由于目标机器主动拒绝而无法建立连接。有人能解决吗?

请您参考如下方法:

我完全遵循了tut你提供了,它对我来说效果很好。

运行日志:

查看网址:

基于错误:

pymongo.errors.ConnectionFailure: [WinError 10061] No connection could be made because the target machine actively refused it.

您似乎没有打开 COSMOS DB 模拟器,请检查它的状态。