Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FATAL: no pg_hba.conf entry for host "fe80::1%lo0"

Can someone help me why this is happening when I'm trying to connect to database or rails s?

In my pg_hba.conf file I have this:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     Andrew                                trust
#host    replication     Andrew        127.0.0.1/32            trust
#host    replication     Andrew        ::1/128                 trust

local all all md5

Maybe I'm doing it wrong?

Thanks

like image 723
hellomello Avatar asked Apr 28 '14 18:04

hellomello


2 Answers

I had the same problem. somehow, this line was added to my /etc/hosts file:

fe80::1%lo0    localhost

commenting out or removing that line from /etc/hosts should fix it

sudo vi /etc/hosts
#fe80::1%lo0    localhost
like image 143
nelsonenzo Avatar answered Oct 06 '22 07:10

nelsonenzo


I'm on OSX 10.9.3 and Postgres 9.3.4.

I've managed to resolve this problem in the following way:

First find your pg_hba.conf file by starting up psql with psql -h 127.0.0.1 and executing SHOW hba_file;:

              hba_file
-------------------------------------
 /usr/local/var/postgres/pg_hba.conf
(1 row)

Now add the following line to pg_hba.conf:

host    all             all             fe80::1%lo0/128         trust

and reload the configuration via select pg_reload_conf(); within psql.

Now you should be able to connect via psql -h fe80::1%lo0.

like image 30
Daniel Avatar answered Oct 06 '22 09:10

Daniel