Database Administration⏱️ 2 min read📅 2026-05-31

How to Fix: psql: FATAL: Peer authentication failed for user "dev"

How to resolve psql peer authentication failed error for a new user in PostgreSQL

Quick Answer: The issue is caused by the default authentication method being set to 'trust' for the new user. To fix this, you need to change the authentication method to 'password'. You can do this by running the following command:  createuser -m dev -P password

To resolve the "Peer authentication failed" error when attempting to login to a PostgreSQL database using a newly created user, follow these steps.

🔧 Proven Troubleshooting Steps

Method 1: Update the PostgreSQL Configuration File

  1. Step 1: Locate the PostgreSQL configuration file, typically located at `/etc/postgresql/common/postgres.conf` or `/var/lib/pgsql/12/main/postgres.conf` (depending on your system version).

Step 2:

  1. Update the `auth_method` parameter to `trust` or `password` (depending on your desired authentication method). For example, add the following line to the file: `auth_method = 'trust'

Method 2: Set Environment Variables

  1. Step 1: Set the `PGAUTH` environment variable to point to a trusted authentication file.

Step 2:

  1. Run the command `export PGAUTH=/etc/postgresql/common/passwd` (or the location of your trusted authentication file).

✨ Wrapping Up

By following these steps, you should be able to resolve the "Peer authentication failed" error and successfully login to your PostgreSQL database using your newly created user.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions