How to use MongoHQ on Heroku without Verifying your Account

This is a repost of Elliot Bradbury’s article, which I found very useful.

Original source is at:


Disclaimer: This post describes a way to use a free Heroku add-on with a free Heroku account, without verifying the account with a credit card. I am in no way intending to defraud Heroku or Heroku add-on providers. This information is for educational purposes only.

For those developers who have been living under a rock, Heroku is a cloud computing PaaS. It supports many languages and frameworks and provides additional features through add-ons.

For my basic usage of Heroku, I wanted to run a small Bottle app on my free account and use MongoDB for data storage. MongoDB is not directly available through Heroku, but there are third-party add-ons that provide it as a service (with free plans). MongoHQ is one of them.

If my Heroku account was verified, I could easily install the MongoHQ add-on using the following command.

$ heroku addons:add mongohq:sandbox
Adding mongohq:sandbox on foo-bar-1234... failed
 !    Please verify your account to install this add-on
 !    For more information, see
 !    Verify now at

But as you can see, the command fails, even when trying to add the free (sandbox) add-on.
Account verification requires a credit card, and I don’t like to toss mine around the internet unless I have to.
Luckily, there is a way around this… It turns out that installing the MongoHQ add-on using the Heroku toolbelt just provisions a database on the MongoHQ platform and sets the MONGOHQ_URL configuration variable to contain the correct database connection string. Both of these things can be done “by hand”.


First, create a database on MongoHQ. Simply sign-up for an account and follow the instructions on their site. After you have a database, copy the Mongo URI from the Admin > Overview page of the database on MongoHQ. It should look like this (host and port may vary):


Fill in any missing info. Example:


Next, using the Heroku Toolbelt, set the MONGOHQ_URL (can actually be named anything) configuration variable to this value.

$ heroku config:set MONGOHQ_URL="mongodb://"

That’s it.

The configuration variable that we set is exposed as an environment variable and can be used to open a connection to the database. The free MongoDB, provided by MongoHQ, is now ready for use.
A Python example:

con = pymongo.Connection(os.getenv('MONGOHQ_URL'))

Do good, not evil.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s