Deploying Strapi with Postgres database to Heroku (bypassing required Credit card)

Dorell James
React Cebu
Published in
4 min readAug 5, 2019

Long story short, Heroku accounts who haven’t entered their credit cards can’t use addons such as mLab and others to deploy Strapi. This guide is basically intended to get around that by using Postgres as our primary database.

The primary motivation of this article is due to the unfortunate event brought by the said limitation in where our participants weren’t able to deploy our backend app.

In order for you or anyone to follow this guide effectively, we’ll be using a repo created beforehand containing a simple content model for a todo app using Postgres database.

And, so let’s get started…

  1. Create a new app on Heroku.

2. Go to Resources tab and let’s add Postgres add-on as this is not restricted to be added. Hopefully, they’ll not change this.

Heroku, I’m watching at you!

So search in the Add-ons search bar, key in “postgres” and you’ll be presented with a dropdown containing an option “Heroku Postgres”.

2.1. Select the suggested option and you’ll be presented with a modal below.

2.2. Click Provision and that’s it. You have added a Postgres database. 😎

3. Now, by doing step 2, we basically also set up a Config Var with DATABASE_URL. You can view this in Settings tab.

4. Let’s set up the needed database config variables to get our Strapi headless CMS up and running.

So based from the DATABASE_URL value: postgres://rmejrriyzxttjz:715c7e46767e990a89e5afdaf1f07185e488005bcd3af253d094921c6040a534@ec2–54–235–96–48.compute-1.amazonaws.com:5432/d9v98qi5j82om6

All we have to do is slice carefully copy values and add each config vars one by one. So based on the above value, we can get the following and add them as follows:

DATABASE_HOST = ec2–54–235–96–48.compute-1.amazonaws.comDATABASE_NAME = d9v98qi5j82om6DATABASE_AUTHENTICATION_DATABASE = d9v98qi5j82om6DATABASE_USERNAME = rmejrriyzxttjzDATABASE_PASSWORD = 715c7e46767e990a89e5afdaf1f07185e488005bcd3af253d094921c6040a534DATABASE_PORT = 5432

And so this is how it looks like once added:

5. Now, let’s go to https://github.com/reactcebu/strapi-todoapi-postgresql and fork it to our GitHub account.

6. And let’s get back to our Heroku app and go to Deploy tab click Connect to GitHub and follow instructions (scroll down below). Once connected by authorizing Heroku on behalf of your GitHub’s account, you’ll be presented an interface to search our forked repo on step 2.

Then we search “strapi-todoapi-postgresql” and click Search button and click Connect button afterwards.

7. Now we’re ready to deploy, so just go down below and click on “Deploy Branch”. Make sure we’re on master branch.

And the building begins…

8. Let’s just wait for it to finish. Once done, click “View App” and Voila! 🎉

Thank you. If this article helped you in some way, please consider by giving a clap and share it with your friends. Thanks once again! :)

--

--