Can't connect to mongodb though webapp


I'm trying to connect my Flask app to a mongodb free instance on

I already read the help page but still get the error:

pymongo.errors.ServerSelectionTimeoutError: <INSTANCENAME> [Errno 111] Connection refused,<INSTANCENAME> [Errno 111] Connection refused,<INSTANCENAME> [Errno 111] Connection refused

My code is:

from pymongo import MongoClient
client = MongoClient('mongodb+srv://<LOGIN>:<PASSWORD>@<INSTANCENAME>', connectTimeoutMS=30000, socketTimeoutMS=None, socketKeepAlive=True, connect=False, maxPoolsize=1)
db = client.newdatabase 
col = db.newcollection

Additionally: - whitelisted the CIDR on my mongoDB instance (can access it directly from my pc) - installed package pymongo[srv]

Thank you.

edit: title through /:

Free accounts can only connect out of PythonAnywhere using http(s) to a whitelist of sites. is on the whitelist, so you can use the mongo http api, but not the server connection (like you're trying to do).