44

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

Andrew
  • 3,839
  • 10
  • 29
  • 42

5 Answers5

40

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

James Kingsbery
  • 7,298
  • 2
  • 38
  • 67
  • 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 05 '13 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. – James Kingsbery Dec 05 '13 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 '18 at 06:46
  • 1
    @Andrew this Answer comes late but, add the path of psql.exe to your Windows environment variables. – Frank Roth Feb 26 '19 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.

Lauris
  • 345
  • 2
  • 8
10

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.

Abhishek
  • 648
  • 7
  • 8
  • 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? – user3132457 Feb 08 '22 at 18:24
  • 1
    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 '22 at 18:45
  • 1
    The "Restrictions" was the answer for me: https://stackoverflow.com/a/15323270/470749 – Ryan Apr 19 '22 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.

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
Ndeto
  • 315
  • 6
  • 17
  • 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? – Harmandeep Singh Kalsi Apr 25 '20 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 '20 at 08: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 – Harmandeep Singh Kalsi Apr 28 '20 at 10:04
0

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

Easy to view enter image description here

Stephy
  • 11
  • 4