{"id":8593,"date":"2024-06-15T08:07:48","date_gmt":"2024-06-15T08:07:48","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=8593"},"modified":"2024-08-05T07:01:00","modified_gmt":"2024-08-05T07:01:00","slug":"fix-peer-authentication-failed-error-in-second-odoo-instance","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/fix-peer-authentication-failed-error-in-second-odoo-instance\/","title":{"rendered":"Fix &#8220;Peer Authentication Failed&#8221; Error in Second Odoo Instance"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 2,244<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p class=\"wp-block-paragraph\">When encountering a &#8220;Peer authentication failed for user&#8221; error while trying to run a second Odoo instance on Ubuntu, it typically indicates an authentication issue between PostgreSQL and the Odoo application. This error commonly arises due to PostgreSQL&#8217;s default authentication method not matching the authentication method expected by Odoo. Here\u2019s how you can resolve this issue:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Understanding the Error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL uses various authentication methods, such as <code>peer<\/code>, <code>md5<\/code>, <code>password<\/code>, etc. The default method <code>peer<\/code> relies on the operating system user credentials, whereas Odoo typically expects a <code>password<\/code> or <code>md5<\/code> authentication method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Resolve &#8220;Peer authentication failed&#8221; Error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these steps to configure PostgreSQL to authenticate properly with your second Odoo instance:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Configure PostgreSQL Authentication Method<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Edit PostgreSQL Configuration<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the PostgreSQL configuration file for editing. It\u2019s usually located at <code>\/etc\/postgresql\/&lt;version&gt;\/main\/pg_hba.conf<\/code>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">     2. <strong>Adjust Authentication Method<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Find the lines that define <code>local<\/code> connections. They typically look like this:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"># \"local\" is for Unix domain socket connections only local all all peer<\/mark><\/code><\/li>\n\n\n\n<li>Change <code>peer<\/code> to <code>md5<\/code> or <code>password<\/code> for the database and user Odoo will connect with. This change ensures PostgreSQL uses a password-based authentication method.<\/li>\n\n\n\n<li>Example:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"># \"local\" is for Unix domain socket connections only local all all md5<\/mark><\/code><br>Here, <code>md5<\/code> indicates PostgreSQL should expect a password to authenticate local connections.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">     3. <strong>Reload PostgreSQL<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After making changes, restart PostgreSQL to apply the new configuration:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">bash sudo systemctl restart postgresql<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. Configure Odoo to Use Password Authentication<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Odoo needs to be configured to authenticate with PostgreSQL using passwords rather than relying on the operating system user credentials (<code>peer<\/code> authentication).<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Update Odoo Configuration<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the Odoo configuration file (<code>odoo.conf<\/code>) for your second instance.<\/li>\n\n\n\n<li>Ensure the <code>db_user<\/code> and <code>db_password<\/code> parameters are correctly set with the PostgreSQL username and password for the second Odoo instance. Example configuration in <code>odoo.conf<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-97c4e0edd72007dabafe07d52300228e\"><code>   <code>&#91;options]\n   db_host = localhost\n   db_port = 5432\n   db_user = odoo_user\n   db_password = your_password<\/code><\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Restart Odoo<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Restart your second Odoo instance to apply the new configuration:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">bash sudo systemctl restart odoo-instance2<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. Test Connection<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">After making these changes, verify if the second Odoo instance can now connect to PostgreSQL without encountering the authentication error.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Check Odoo Logs<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check the logs of your second Odoo instance (<code>\/var\/log\/odoo\/odoo-instance2.log<\/code>) for any PostgreSQL-related errors.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">     2. <strong>Connectivity Test<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Attempt to access the Odoo web interface of the second instance. If the page loads without errors, it indicates successful connection to the database.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Additional Considerations<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Security<\/strong>: Ensure that you use strong passwords and follow best practices for securing PostgreSQL and Odoo instances.<\/li>\n\n\n\n<li><strong>Backup<\/strong>: Before making significant changes to configuration files, always back up your data to prevent accidental data loss or corruption.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">By configuring PostgreSQL to use a password-based authentication method (<code>md5<\/code>) and ensuring Odoo\u2019s configuration matches this setup, you should be able to resolve the &#8220;Peer authentication failed for user&#8221; error and successfully run multiple Odoo instances on your Ubuntu server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Resolving the \u201cPeer authentication failed for user\u201d error, you can follow the troubleshooting steps to configure the PostgreSQL Authentication Method and use of the password-based authentication method and verify the odoo configurations with this setup. After following all of these steps, you can resolve the Peer authentication failed for user\u201d error and successfully run multiple Odoo instances on your Ubuntu server, which is part of the <a href=\"https:\/\/www.infinitivehost.com\/managed-odoo-server-solutions\"><strong><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">best Odoo server solutions<\/mark><\/strong><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2,244 Views When encountering a &#8220;Peer authentication failed for user&#8221; error while trying to run a second Odoo instance on Ubuntu, it typically indicates an authentication issue between PostgreSQL and the Odoo application. This error commonly arises due to PostgreSQL&#8217;s default authentication method not matching the authentication method expected by Odoo. Here\u2019s how you can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[203],"tags":[],"class_list":["post-8593","post","type-post","status-publish","format-standard","hentry","category-odoo"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=8593"}],"version-history":[{"count":3,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8593\/revisions"}],"predecessor-version":[{"id":8807,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8593\/revisions\/8807"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=8593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=8593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=8593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}