Enable Dark Mode!
how-to-solve-the-peer-authentication-failed-issue-in-odoo.jpg
By: Adwaith SS

How to Solve the Peer Authentication Failed Issue in Odoo

Technical Odoo 15

While setting up the Odoo environment in your system it is probable that you might encounter “failed: FATAL:  Peer authentication failed”,  which arrives when you try to login to your PostgreSQL user but authentication fails because by default psql connects over UNIX sockets using peer authentication instead of password authentication.

If you try to access the odoo from your browser your screen might display as follows:

how-to-solve-the-peer-authentication-failed-issue-in-odoo

If you check your terminal logs the output will be similar to the image given below:

how-to-solve-the-peer-authentication-failed-issue-in-odoo

There could be several reasons for this error to occur such as:

- Incorrect database credentials provided in the configuration (odoo.conf) file

- Inconsistency in ‘pg_hba.conf’

Let’s see how we can update the ‘pg_hba.conf’ file to assign the database user to solve the issue.

Open your terminal and enter the following commands

how-to-solve-the-peer-authentication-failed-issue-in-odoo

cd /etc/postgresql

ls

cd 12/main/

sudo gedit pg_hba.conf

Then you can add your information accordingly as follows (you should provide your database user name)

how-to-solve-the-peer-authentication-failed-issue-in-odoo

After saving this file you have to restart your postgresql service using the following command:

sudo service postgresql restart.

how-to-solve-the-peer-authentication-failed-issue-in-odoo

Now you can access your Odoo database.

how-to-solve-the-peer-authentication-failed-issue-in-odoo

If you give md5 instead of trust you have to provide the exact db_password in your ‘odoo.conf‘ file.

- Peer (or trust) means it will trust the authenticity of a UNIX user and hence does not prompt for the password.

- md5 means it will always ask for a password, and validate it after hashing with MD5.

In case the above-mentioned solution didn’t work for you, changing postgres user’s password may solve the problem. 

PostgreSQL is provided with a default user named ‘postgres’. For this, we will use this role and change its password. Run the following command to jump into postgreSQL cmd.

sudo -u postgres psql postgres

Enter your root/sudo password. This will take you to the psql cmd which will be prompted.

Here ‘postgres’ is the username you’re currently logged in with. Now run the following command to change the password.

\password postgres

how-to-solve-the-peer-authentication-failed-issue-in-odoo

This will prompt you to enter your new password for user ‘postgres’ and then will ask you to confirm it by re-entering it. You’re done with a possible second solution. Go to database.yml file and update the password for ‘postgres’ username according to your new password. Now run the command to create DB.


If you need any assistance in odoo, we are online, please chat with us.



1
Comments

Van Bernaert

Glad this helped resolving my problem. But what is the cause of this problem? I faced this problem all of sudden after a reboot, on a server that is running since 1 year, no new updates or addon's.

17/11/2023

-

10:54AM



Leave a comment

 


whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message