问题
When I go to my Apps in Heroku and check the resources I can see Postgresql
but when I run from my computer pg:info I get the following:
$ heroku pg:info
! Resource not found
or this:
$ heroku pg:wait
! Resource not found
although when I run pg:credential I do get an output:
$ heroku pg:credentials HEROKU_POSTGRESQL_PINK
Connection info string:
"dbname=some_name host=ec2-107-22-165-15.compute-1.amazonaws.com port=5432 user=some_user password=some_password sslmode=require"
I have tried running heroku run rake db:migrate
, heroku run db:reset
and all fail.
I get the errors:
could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?
Going to the settings through the heroku web, I can see the following:
Connection Settings : Default
Host ec2-107-22-165-15.compute-1.amazonaws.com
Database some_databasename
User some_user
Port 5432
Password some_password
Statistics
Plan Dev
Status available
Data Size 5.9 MB
Tables 0
PG Version 9.1.8
Created March 27, 2013 18:01
heroku config
has DATABASE_URL and HEROKU_POSTGRESQL_PINK_URL set.
I have erased the production
section of database.yml
as I understand Heroku creates its own database.yml
I just migrated to ruby 2.0 and rails 4.0
how should I connect to the database? I thought this was supposed to be automatic. Thanks
回答1:
Solved this by downgrading Rails and Ruby :(
Now I'm using rails 3.1.0 and ruby 1.9.3
回答2:
Seems like the issue is with an outdated heroku toolbelt version. I was using v2.19.2.
Installing heroku toolbelt via ruby gems is deprecated, best thing to do is uninstall heroku gem $ gem uninstall heroku
and reinstall the toolbelt the prefered way, depending on your platform: https://toolbelt.heroku.com/
来源:https://stackoverflow.com/questions/15667551/heroku-postgres-not-found