Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Heroku Postgres using SSH (Putty)

I'd like to be able to connect to my Heroku postgres (crane) database from my desktop using Putty.

I recently moved from Webfaction to Heroku. On webfaction this was a really simple process (via their docs: http://docs.webfaction.com/user-guide/databases.html#starting-an-ssh-tunnel-with-putty).

Heroku lets you get your database info and credentials using heroku pg:credentials. Shown here: https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress. I can't seem to figure out how to connect to the database through Putty using this info.

If I try to set things up with the Heroku info Putty gives this error: Disconnected: No supported authentication methods available.

like image 858
James Avatar asked May 27 '13 17:05

James


3 Answers

Heroku listens for SSL connections to the database, but doesn't provide a shell account, as would be required to use Putty. They say in their doc:

When you find yourself wanting SSH access, instead try using tools that properly accounts for Heroku’s distributed environment, such as the heroku command line tool and one-off dynos.

And indeed, this contrasts with Webfaction which clearly states that they offer shell access:

Full shell access to fast servers with all your favorite tools pre-installed and maintained for you.

Different companies, different services...

like image 77
Daniel Vérité Avatar answered Sep 25 '22 00:09

Daniel Vérité


Use the following command literally : heroku pg:psql DATABASE

This will match the config string DATABASE_URL and connect you to your database with psql.

Note : you may have to add psql to your PATH

On Mac OS, with the PostGres App :

export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH

like image 29
yanjost Avatar answered Sep 25 '22 00:09

yanjost


Heroku permit direct connection to the databases, you don't have to use putty or another ssh client to tunnel to the database server.

Use your Heroku postgres credentials to connect directly with psql from your command line.

like image 41
John Beynon Avatar answered Sep 25 '22 00:09

John Beynon