43

Now that I've deployed my webapp to Heroku, how would I be able to browse the database as it's altered over time?

1
  • Is it postgres? You should be able to connect to it using psql. What have you tried? Dec 5, 2013 at 21:17

5 Answers 5

40

Try heroku pg:psql. For instructions for how to do this, see this.

4
  • 3
    I'm running Windows, and I installed PostgreSQL, however when I run that command, I get an error saying "The local psql command could not be located".
    – Andrew
    Dec 5, 2013 at 21:28
  • If you read the link I provided, you'll see that it says you need to install postgres locally. It has instructions for doing so in Windows. Dec 5, 2013 at 21:49
  • 1
    for running it on windows, you need to have Postgres installed locally and then you need to add the path to the bin folder of Postgres to the PATH environment variable. Once that is done, you should be able to run heroku pg:psql from powershell.
    – Sumit
    Apr 15, 2018 at 6:46
  • 1
    @Andrew this Answer comes late but, add the path of psql.exe to your Windows environment variables.
    – Frank Roth
    Feb 26, 2019 at 18:44
20

If you want to browse your Heroku PostgreSQL database using a browser there is now a free tool for that called Heroku Data Explorer: https://datazenit.com/heroku-data-explorer.html

It uses Heroku API in real time so your data/credentials stay secure and private. Also it has excellent performance because Heroku local network is used for database connections.

1
  • 1
    This appears to only have a 7-day free trial now.
    – Optimus
    Apr 25, 2022 at 11:59
9

Download PgAdmin 4 and configure your heroku database credentials. Right click on Servers link and choose create >> server. On General tab give Name as per your wish and on Connection tab enter Hostname/address, address, Maintenance database (database name), Username and password which is given in Heroku dabase credentials page. And you will be able to access heroku dadabase on UI free of cost.

3
  • 1
    i was able to connect to the heroku pg database first time, now i want to connect again (after closing pgAdmin), it says server closed the connection unexpectedly. i know that heroku rotates credentials, so i tried to add a new server with current credentials, with no success. heroku pg:psql fails too. any idea what could be wrong? Feb 8, 2022 at 18:24
  • I tried this, but pgAdmin 4 then shows a list of 6625 databases, none of which match what I entered into the server connection form.
    – Ryan
    Apr 19, 2022 at 18:45
  • The "Restrictions" was the answer for me: stackoverflow.com/a/15323270/470749
    – Ryan
    Apr 19, 2022 at 18:52
1

I use a tool called Adminer to connect to the DB. The problem is that Heroku will change the credentials for the DB occasionally. You can find them by visiting the Resources tab on your Dashboard then clicking on the DB you use.

It will take you to the Addons page in another tab. Click on the Settings tab then View Credentials.

Using these credentials, you can use Adminer to login to the DB.

3
  • I tried connecting to Heroku Postgresql using Adminer , it gives this error: Unable to connect to PostgreSQL server: FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege. Could you please let me know what could be the problem here? Apr 25, 2020 at 20:35
  • Sorry i'm a bit late. Did you get your credentials from Heroku Postgres add-on page? When i get that, it's usually wrong credentials
    – Ndeto
    Apr 27, 2020 at 8:34
  • yes I did get the connection details but using Adminer not able to connect. So I chose the pgAdmin approach to connect to that database Apr 28, 2020 at 10:04
0

Install Beekeeper Studio. Connect to POSTGRES_URL of Heroku with "SSL" enabled.

Easy to view enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.