psql: FATAL: no pg_hba.conf entry for host “[local]”, user “root”, database “root”, SSL off

If you see the above error, open pg_hba.conf  file (/var/lib/pgsql/data/pg_hba.conf) and uncomment or add the line :
local all all trust
Then restart postgresql
# /etc/init.d/postgresql restart

About Sarath

A Techie from Kochi, India with 8+ years of experience in Linux and Windows server administration. I learn new things almost everyday and I enjoy the fun of learning and sharing my knowledge.

Related Posts

COMMENTS

2 thoughts on “psql: FATAL: no pg_hba.conf entry for host “[local]”, user “root”, database “root”, SSL off

  1. I show error like this…

    192.168.100.133 – – [Mon, 19 Aug 2013 12:01:32 GMT] "GET /?callback=xxx&_=1376913692899 HTTP/1.1" 200 – "http://localhost/node/node-run-from-here/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4"
    17:31:33 web.1 | { [error: no pg_hba.conf entry for host "115.254.30.193", user "xxxxx", database "xxxxx", SSL off]

    Please reply me as soon as possible about solution….

  2. Sorry for the late reply. Are you trying to connect remotely to PostgreSQL? By default PostgreSQL refuses all connections it receives from any remote address. When a connection is initialized, PostgreSQL will read through the pg_hba.conf one entry at a time, from the top down. As soon a matching record is found, PostgreSQL will stop searching and allow or reject the connection, based on the found entry. If PostgreSQL does not find a matching entry in the pg_hba.conf file, the connection fails completely.

    You will need to add:
    =====================

    1. In : /var/lib/pgsql/data/postgresql.conf:

    listen_addresses = 'xxx.xxx.xxx.xxx' (Use * if you want to allow connections from every IP)

    2. In : /var/lib/pgsql/data/pg_hba.conf:

    local all all xxx.xxx.xxx.xxx trust

    Replace xxx.xxx.xxx.xxx with IP(s) or with network from which you want to connect remotely.

    You can replace both "all" with database name and database user name respectively if you want to restrict access.

    Eg :

    local db_name db_user 115.254.30.193 trust

    You can use md5 auth-method as well instead of trust if you want users to connect to PostgreSQL with a valid password.

    Hope that helps. If you have any further queries, feel free to let me know..

Leave a Reply

Your email address will not be published. Required fields are marked *