I am going through Heroku's getting started tutorial. As far as I know, Postgres is fully updated and everything is installed appropriately. Interestingly, the app works online when I deploy it to heroku, but when I try to run the app locally, not so much! I am getting a:
PG::ConnectionBad
could not translate host name "myname" to address: Temporary failure in name resolution
### Convenience alias for PG::Connection.new.
def self::connect( *args )
return PG::Connection.new( *args )
end
I have not touched any information in the files created by Heroku for this tutorial - so what could be wrong?
The following commands were run:
heroku login
git clone https://github.com/heroku/ruby-getting-started.git
cd ruby-getting-started
heroku create
git push heroku main
heroku open (this gets to the app okay)
heroku logs --tail
which psql
bundle install
export DATABASE_URL=postgres://$(whoami)
bundle exec rake db:create db:migrate (Here is where the error is)
heroku local web
(Error here) http://localhost:5000/
Confirm that Postgres exists in yout local machine, is running and it have a user that maches with you machine username.
Try to run this command in your local machine:
psql -U $(whoami) -d postgres
The output should be something like this:
psql (9.2.24, server 10.14)
WARNING: psql version 9.2, server version 10.0.
Some psql features might not work.
Type "help" for help.
postgres=#
Then, confirm that a database matching with your username exists with "\l".
postgres=#\l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+----------+----------+-------------+-------------+-----------------------
myuser | odoo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
tip: you can close with "\q"
postgres=#\q
if no error, try replacing the value of DATABASE_URL with one of the following...
postgresql://
postgresql://localhost
postgresql://localhost:5433
postgresql://localhost/mydb
postgresql://user@localhost
If this is not successful, then you must review the way that postgres is installed.
...Or manually create a superadmin User with a password inside Postgres.
The conection string pattern is postgres://user:password@host:port
example...
export DATABASE_URL=postgres://db_user:123456@localhost:5432
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With