简体   繁体   中英

Postgres pg_hba.conf

There is server being set-up for one of my client, after installations of postgres when we run the server we are encountering the error below. When I goggled for it there were a few solutions available but none worked for me, could you look into it and say what's happening.

Status: 500 Internal Server Error
FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "syr_admin", database     "allprosh_production", SSL off

My pg_hba.conf file:

local all  all      md5
host samerole all  127.0.0.200   255.255.255.255   pam  pamservice=postgresql_cpses
host samerole all  127.0.0.1   255.255.255.255   md5
local all postgres        md5
host all postgres  127.0.0.1   255.255.255.255   md5
local   all     all     trust  

Thanks in Advance.

I figured it out myself, though it took a long time. The solution was simple, I just had to add an entry in the pg_hba.conf file for that particular user. This is what I did:

local all syr_admin  md5
host all syr_admin 127.0.0.1   255.255.255.255   md5

Hope this helps others... :-)

I think that the just configuration is:

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0               md5

If you want connect by other network use:

host    all             all             network address/32            md5

use the two octet 192.159.0.0 for example

I reply here cause I can't comment your solution.

It is not mandatorry to add the entry to that specific user only. You can replace the option "samerole" with the database or all.

I'm seeing that 2 of the lines that you have are collisioning each other.

local all  all      md5
local   all     all     trust  

In this case, last line wins, so be careful to add unexpected behaviors on your access methods. If you want to ask the password for the universe on local, you must delete the last line.

Hope that this helps !

For the localhost authentification on PostgreSQL with the user postgres , your hba.conf must have this line :

# IPv6 local connections:
host    all             postgres             ::1/128             trust

For to be sure, you can add this other line :

# IPv4 local connections:
host    all             postgres          127.0.0.1/32           trust

Note : You can change the method ao authentification from trust to md5 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM