← Back to all articles
SoftwareTutorialsJanuary 24, 2021Arash Farahani

KeystoneJs work-around to Heroku mLab MongoDB Add-on Shutdown

Published on January 24, 2021
KeystoneJs work-around to Heroku mLab MongoDB Add-on Shutdown

Back in October, I got an email from Heroku saying that mLab MongoDB add-on is going away and I need to remove it from my Heroku App i.e. my personal website. Here were their recommended next steps

You may wish to consider an alternative data store add-on from the Heroku Elements Marketplace, such as the ObjectRocket for MongoDB add-on (available as of the date of this email). For customers who are considering remaining with mLab/Atlas, information can be found here.

All those options are paid except for mlab/Atlas. From the link provided, I could migrate my data to a free Atlas MongoDB cluster. But my website was down since I hadn’t connected it to the new database.

Here are the easy steps to do it:

Grant authorized IP addresses access to your cluster

This is the last step in setting up your cluster. You choose which IP addresses are allowed to access it. To quickly get up and running, set your cluster to allow access from anywhere:

MongoDB Atlas Allow Access from Anywhere

Get your Atlas cluster connection string

Head back to your Atlas cluster’s dashboard as we’ll need to grab our connection string.

Click the “Connect” button.

Choose the “Connect your application” option.

Here, you’ll see the connection string we’ll need to connect to our cluster. For Keystone JS, choose Node.js and the version of mongodb package. I had a version less than 3.0, so my connection string needed to start with mongodb://, not mongodb+srv://. Atlas, takes care of this for you if you choose the appropriate version.

Copy the connection string, and fill in the username, passoword (found in “Database Access” in Atlas console), and database name (found under cluster “Collections”.

Set a MONGODB_URI config var in Heroku

Head to your Heroku app’s settings, click “Reveal Config Vars” and add MONGODB_URI key. Paste your MongoDB connection string from the previous step as it’s value.

You should be up and running. If you are running into any issues, check (or add and check) your logs in the free Papertrail add-on of Heroku.

Other Resources: Use Atlas in Heroku

Share this piece
PostLinkedIn

Substack & Newsletter Syndication

Enjoyed this piece? This post is syndicated to Substack and RSS. Subscribe directly or follow the live feed to receive new deep-dives in your inbox.

Follow RSS FeedContact Arash