RT Cannot Connect to Local PostgreSQL Service with postgres User

I’m configuring a new RT 4.4.2 installation and am following the guide here: CentOS7Install - Request Tracker Wiki. 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

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.

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

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…

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

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!

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…

hi everyone:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/etc/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-04-11 01:33:54 PDT; 1h 23min ago
Process: 9239 ExecStop=/usr/bin/pg_ctl -s -D {PGROOT}/data stop -m fast (code=exited, status=0/SUCCESS) Process: 9256 ExecStart=/usr/bin/pg_ctl -s -D {PGROOT}/data start -w -t 120 (code=exited, status=0/SUCCESS)
Process: 9248 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
Main PID: 9258 (postgres)
CGroup: /system.slice/postgresql.service
├─9258 /usr/bin/postgres -D /var/lib/postgres/data
├─9259 postgres: logger process
├─9261 postgres: checkpointer process
├─9263 postgres: writer process
├─9264 postgres: wal writer process
├─9265 postgres: autovacuum launcher process
└─9266 postgres: stats collector process

Apr 11 01:33:53 localhost.localdomain systemd[1]: Starting PostgreSQL databas…
Apr 11 01:33:54 localhost.localdomain systemd[1]: Started PostgreSQL database…
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# make initialize-database
make: *** No rule to make target `initialize-database’. Stop.
[root@localhost ~]#
my postgres db is up when i try make initialize-database i got the above error pls how can i sort it out.
thank you.
regards.

  1. trust connection by adding in pg_hba.conf file
  • local all postgres trust
  1. Restart postgresql service
  • sudo service postgresql restart
  1. psql -U postgres
  2. At the postgres=# prompt, change the user name postgres password:
  • ALTER USER postgres with password ‘new-password’;
  1. Revert the changes in pg_hba.conf file from trust to md5 and restart postgresql
    yet when i try to test psql -U postgres -W
    it will give me this error:
    [root@localhost rt-4.4.3]# psql -U postgres -W
    Password for user postgres:
    psql: FATAL: Peer authentication failed for user “postgres”
    [root@localhost rt-4.4.3]#
    pls how can i go about this?

hi everyone, thank you for your supports i have been able to fix peer: Fatal peer authentication failed for user “postgres”
[root@localhost rt-4.4.3]# psql -U postgres -h 192.168.40.142
Password for user postgres:
psql (9.2.24)
Type “help” for help.

postgres=# l+
postgres-# \q
[root@localhost rt-4.4.3]# make initialize-database
/usr/bin/perl -I/opt/rt4/local/lib -I/opt/rt4/lib sbin/rt-setup-database --action init --prompt-for-dba-password
In order to create or update your RT database, this script needs to connect to your Pg instance on localhost (port ‘’) as postgres
Please specify that user’s database password below. If the user has no database
password, just press return.

Password:
Working with:
Type: Pg
Host: localhost
Port:
Name: rt4
User: rt_user
DBA: postgres
Now creating a Pg database rt4 for RT.
Done.
Now populating database schema.
Done.
Now inserting database ACLs.
Done.
Now inserting RT core system objects.
Done.
Now inserting data.
Done inserting data.
Done.
hi everyone, pls the guide am using stop at make initialize-database which i have done and it’s fine, the database am using is postgres9.2.
pls friends what should i do next.
thank you.

Last login: Fri Apr 17 20:28:04 2020 from 192.168.40.1
[root@localhost ~]# cd /tmp/rt-4.4.3/
[root@localhost rt-4.4.3]# psql -U postgres -h 192.168.40.132
psql: could not connect to server: Connection refused
Is the server running on host “192.168.40.132” and accepting
TCP/IP connections on port 5432?
[root@localhost rt-4.4.3]# sudo -u postgres psql
Password:
psql (9.2.24)
Type “help” for help.

postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
[root@localhost rt-4.4.3]# make initialize-database
/usr/bin/perl -I/opt/rt4/local/lib -I/opt/rt4/lib sbin/rt-setup-database --action init --prompt-for-dba-password
In order to create or update your RT database, this script needs to connect to your Pg instance on localhost (port ‘’) as postgres
Please specify that user’s database password below. If the user has no database
password, just press return.

Password:
Working with:
Type: Pg
Host: localhost
Port:
Name: rt4
User: rt_user
DBA: postgres
Now creating a Pg database rt4 for RT.
Done.
Now populating database schema.
Done.
Now inserting database ACLs.
Done.
Now inserting RT core system objects.
Done.
Now inserting data.
Done inserting data.
Done.
[root@localhost rt-4.4.3]# sudo -u postgres psql


after RT_SiteConf i try to login via my web broswer and this is the result am getting pls how can i resolve it.
thank you.

Did you setup Apache to point to the rt-server? There are examples in the “web deployment” section of the RT docs, on mobile so I don’t have links

thank you for your assist and but pls can you help me with the path to setup Apache to piont to rt-server.