I'm having problems with the MongoHQ Heroku addon. Locally, my application works, and the os variable is present and well-formed on Heroku. However, when I try to access db, it throws an error: OperationFailure: database error: unauthorized db:my_database ns:my_database.cars lock type:0 client:128.62.187.133 . If I try to hardcode the connection string from MongoHQ and run locally, I get the same error.
My app is below:
import os import datetime from flask import Flask from flask import g from flask import jsonify from flask import json from flask import request from flask import url_for from flask import redirect from flask import render_template from flask import make_response import pymongo from pymongo import Connection from bson import BSON from bson import json_util app = Flask(__name__) def mongo_conn():
Edit: MongoHQ support helped me. The problem was that I called my database my_database instead of the actual database name provided to me by the MongoHQ addon. For example, db = connection.app52314314 . This change fixed it.
source share