2
votes

I am build a Flask app using Azure Cosmos DB for MongoDB API and I am having a connection error in the following lines. I am following this tut: https://github.com/Azure-Samples/CosmosDB-Flask-Mongo-Sample

I am getting error in the following line:

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

When I run the flask server, I get this error: pymongo.errors.ConnectionFailure: [WinError 10061] No connection could be made because the target machine actively refused it. Can anyone resolve it?

2

2 Answers

1
votes

I totally followed the tut you provided and it works fine for me.

Run LOG:

enter image description here

View URL:

enter image description here

Based on the error:

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

It seems that you didn't open COSMOS DB emulator,please check the status of it.

enter image description here

0
votes

Try to run the emulator with the command from the cmd:

> cd "C:\Program Files\Azure Cosmos DB Emulator"
> .\CosmosDB.Emulator.exe /EnableMongoDbEndpoint