0

Trying to run my Rails 4.0.4 (Ruby 2.1.1) application on CentOS 6.5

Failing when I attempt to migrate:

$ rake db:migrate
rake aborted!
PG::ConnectionBad: FATAL:  no pg_hba.conf entry for host "::1", user "my_user", database "my_database_dev", SSL off

I am not sure how to tackle this one. On my mac setup all worked fine without having to touch the pg_hba.conf.

Any lead is welcome.

I have created my_user as follow:

CREATE ROLE my_user WITH CREATEDB SUPERUSER LOGIN;

And allowed my_user to access all database with 'trust' in the pg_hba.conf

my config/database.yml contains

development:
  adapter:  postgresql
  host:     localhost
  encoding: unicode
  database: my_database_dev
  pool:     5
  username: my_user
  password:
  template: template0
zabumba
  • 12,172
  • 16
  • 72
  • 129

2 Answers2

0

It looks like rake is for some reason passing a bad host, as I assume ::1 is not the name of your server (it looks more like an IP mask of sorts from the Postgres config). (Edit: ::1 is IPv6 localhost, per Doon's comment below.)

Not sure offhand why the same code would work OK on your Mac, but I assume there's a database.yml involved in your Rails config? You may want to try specifying a host attribute in there (it can point to localhost if your server is local) and see if that helps.

i.e.

host: localhost

You'd also want to include one for the port if Postgres is not on the standard port for your Postgres install (5432 with a default install).

khampson
  • 14,700
  • 4
  • 41
  • 43
0

::1 is localhost in ipv6. Your PostgreSQL config doesn't have a config for v6. Try setting your server to 127.0.0.1 the ipv4 address of localhost.

Doon
  • 19,719
  • 3
  • 40
  • 44