I have a Flask app that I am deploying to Heroku that I want to connect to a MongoDB instance using mongoengine
. It looks like this:
if __name__ == '__main__':
mongo_host = os.environ.get('MONGODB_URI')
connect(alias='default', host=mongo_host)
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=True)
I'm able to connect to this instance on localhost but when I try to run it on Heroku I get this error: mongoengine.connection.MongoEngineConnectionError: You have not defined a default connection
What am I doing wrong?
UPDATE:
I'm using mongoengine version 0.13.0 on both localhost and Heroku deploy