RT Cannot Connect to Local PostgreSQL Service with postgres User


#1

I’m configuring a new RT 4.4.2 installation and am following the guide here: https://rt-wiki.bestpractical.com/wiki/CentOS7Install. The dependency installation went by just fine and I haven’t had any issues up until this point.

The issue I’m having is that at the database initialization step:

make initialize-database

I’m apparently having trouble with the RT service connecting to the database via the default postgresql user.

Now I’ve changed the password using the following:

sudo -u postgres psql
ALTER USER postgres PASSWORD ‘xxx’;
\q

And I can log in just fine using the same line and my updated password on the command line. The full error I get at the command line if using sudo make initialize-database is:

Password:
Working with:
Type: Pg
Host: localhost
Port:
Name: rt4
User: rt_user
DBA: postgres
Failed to connect to dbi:Pg:dbname=template1;host=localhost as user ‘postgres’ : FATAL: Ident authentication failed for user "postgres"make: *** [initialize-database] Error 255

My /var/lib/pgsql/data/pg.hba file looks like:

TYPE DATABASE USER ADDRESS METHOD
#“local” is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident

And if I’m trying the web configuration page I get an error at the top:

Failed to connect to database: FATAL: Ident authentication failed for user “postgres”

All of this makes me think my password is incorrect, but I’ve changed it many times and can log in just fine via terminal.

This is for installing RT 4.4.2. I am on PostgreSQL version 9.2.23, CentOS Linux 7 Kernel: Linux 3.10.0-862.3.2.el7.x86_64


#2

You have to accept md5 (password) on the local unix socket only. Via network localhost you only accept ident authentication, i.e. the username of the logged in user. You used the latter with ‘sudo -u postgres psql’.

Run

psql -h localhost -U postgres

as any user to “simulate” that. Right now, you’ll see the same error.

Thus either reconfigure the connection to use the unix socket instead of the networked localhost connection or add md5 authentication to the localhost connections.


#3

Hi There,

I have exactly the same issue.
I have found this worked:

sudo -u postgres psql postgres
psql (9.2.23)
Type "help" for help.

postgres=# \password postgres
Enter new password: 
Enter it again: 
postgres=# \q
  1. Restart PostgreSQL:

    sudo service postgresql restart

  2. To test your connection using psql, run the following command:

    psql -U postgres -W

  3. and enter your password when prompted. You should be able to access the psql console as below:

    psql -U postgres -W
    Password for user postgres:
    psql (9.2.23)
    Type "help" for help.
    postgres=# \q

i then started the web server and configured it onward

Les


#4

Well, then I would say you don’t have the same pg_hba configuration or you configure the database connection differently. If you connect to localhost and you don’t allow password authentication on the localhost connection to postgres then it doesn’t work, whatever password you may have…


#5

I did end up changing the IPv4 connections to md5, it seemed like the simplest solution and works for me. Thanks!


#6

Hi jvshens, can you please help me? I got the same exact error. I change to md5 but still get the same error after issuing

make initialize-database

Failed to connect to dbi:Pg:dbname=template1;host=localhost as user ‘postgres’: FATAL: Ident authentication failed for user "postgres"make: *** [initialize-database] Error 255

and after trying to start a server i get an error

/opt/rt4/sbin/rt-server

[warning]: DBI connect(‘dbname=rt4;host=localhost’,‘rt_user’,…) failed: FATAL: Ident authentication failed for user “rt_user” at /usr/local/share/perl5/DBIx/SearchBuilder/Handle.pm line 105. (/usr/share/perl5/vendor_perl/Carp.pm:102)

My /var/lib/pgsql/data/pg_hba.conf file looks like this per instructions:

TYPE DATABASE USER ADDRESS METHOD

“local” is for Unix domain socket connections only

local all all md5

IPv4 local connections:

host all all 127.0.0.1/32 md5

IPv6 local connections:

host all all ::1/128 ident

Allow replication connections from localhost, by a user with the

replication privilege.

#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident

Please help!


#7

Sorry, but it is pretty much impossible to help with that little information. Your unknown rt installation on your unknown operating system with an unknown postgres version and an unknown rt configuration does not work properly… Properly formatting your copied text would also be extremely helpful…

The error message says that you connect to localhost and ident fails. Thus, most likely you connect to postgresql on localhost with IPv6 which you have configured with ident.

Configuring authentication for IPv4 and IPv6 differently on the same hostname is generally a very bad idea.

postgresql also writes log messages in the pgsql data/pg_log directory which gives you more insight to the rejected connection.

More is impossible to say with all the basic information missing in your post…