Setting Laravel Database (PostgreSQL) at Heroku

Ryan Adhitama Putra
2 min readApr 21, 2021

Hello everyone, this is a second part of my post. Next step, we will configure database setting. Generally, we use MySQL, but if we use MySQL, we need to upgrade our membership. That’s why in this tutorial, we will be using PostgreSQL because it’s free.

PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the Ingres database developed at the University of California, Berkeley.

Next step, add heroku-postgresql to your heroku app. Just type and run in your terminal.

$ heroku addons:create heroku-postgresql:hobby-dev

To see your database config.

$ heroku pg:credentials:url

Next step, add postgress credentials into heroku config environment.

$ heroku config:add DB_CONNECTION=pgsql
$ heroku config:add DB_HOST=ec2-3-233-7-12.compute-1.amazonaws.com
$ heroku config:add DB_PORT=5432
$ heroku config:add DB_DATABASE=de7n6sepn1s59b
$ heroku config:add DB_USERNAME=fanztkdsocqyzo
$ heroku config:add DB_PASSWORD=9d143ecc0912810b6edac892852ab0bad7656382707c4b5ddb872bc7e589efe5

If you config database environment correctly, the result is …

Congrats, your database setting is already connect.

--

--