How to fix FATAL: no password supplied in PostgreSQL

PostgreSQLINTERMEDIATEHIGHUpdated Dec 25, 2025· 270 views

This error occurs when a PostgreSQL client attempts to connect to a database but fails to provide authentication credentials. It happens when the user lacks a password, the .pgpass file is misconfigured, or environment variables aren't set properly.

Quick fix

Fixes FATAL: no password supplied

-- List users and their password status
SELECT usename, usecanlogin FROM pg_user WHERE usename = 'yourUsername';

-- Check if password is set (encrypted passwords will be visible)
SELECT usename, valuntil FROM pg_user WHERE usename = 'yourUsername';
  1. Verify the user has a password set in PostgreSQL
  2. Set up a .pgpass file for automatic authentication
  3. Use PGPASSWORD environment variable for one-off commands
  4. Prompt for password interactively with psql
postgresql — error
-- List users and their password status
SELECT usename, usecanlogin FROM pg_user WHERE usename = 'yourUsername';
-- Check if password is set (encrypted passwords will be visible)
SELECT usename, valuntil FROM pg_user WHERE usename = 'yourUsername';
FATAL: no password supplied

What this error means

PostgreSQL's libpq authentication layer is rejecting the connection attempt because no password was provided during the authentication handshake. This error typically appears when connecting to a PostgreSQL server that requires password-based authentication (SCRAM-SHA-256, MD5, or plain password methods) but the client hasn't supplied credentials. The error can occur with command-line tools like psql, pg_dump, or programmatic clients that don't handle password input correctly.

Typical symptoms

  • psql or pg_dump commands fail with 'fe_sendauth: no password supplied' message
  • Connection refused when attempting to connect to PostgreSQL without providing a password
  • Streaming replication fails with this error on PostgreSQL standby servers
  • Remote database connections fail when running from scripts or cron jobs
  • Docker containers or applications cannot connect to PostgreSQL databases

Common causes

  1. The user account exists in PostgreSQL but has no password set (created without one)
  2. The .pgpass file is missing, incorrectly formatted, or has wrong file permissions
  3. The PGPASSWORD environment variable is not set or is empty
  4. The connection string or psql command line omits the -W flag to prompt for password
  5. Connection credentials are passed to a tool that expects them in a different format
  6. pg_hba.conf authentication method expects a password but none is being provided
  7. For applications: password parameter is missing from the connection configuration

How to fix "FATAL: no password supplied"

1Verify the user has a password set in PostgreSQL

Connect to PostgreSQL as a superuser (postgres) and check if the user has a password:

sql
-- List users and their password status
SELECT usename, usecanlogin FROM pg_user WHERE usename = 'yourUsername';

-- Check if password is set (encrypted passwords will be visible)
SELECT usename, valuntil FROM pg_user WHERE usename = 'yourUsername';

If the user has no password or valuntil is NULL, you need to set one:

sql
ALTER USER yourUsername WITH PASSWORD 'newPassword';

For new users, create them with a password:

sql
CREATE USER newuser WITH PASSWORD 'initialPassword';
2Set up a .pgpass file for automatic authentication

Create a ~/.pgpass file to store connection credentials securely:

bash
# On Linux/macOS
cat > ~/.pgpass << EOF
localhost:5432:mydatabase:myuser:mypassword
EOF

# Set restrictive permissions (required for pgpass to work)
chmod 600 ~/.pgpass

Format: hostname:port:database:username:password

Use * to match any value:

bash
*:5432:mydatabase:myuser:mypassword

Now psql will use this file automatically:

bash
psql -h localhost -U myuser -d mydatabase
3Use PGPASSWORD environment variable for one-off commands

For non-interactive scripts or quick connections, use the PGPASSWORD environment variable:

bash
export PGPASSWORD='mypassword'
psql -h localhost -U myuser -d mydatabase -c 'SELECT 1;'
unset PGPASSWORD

Or inline:

bash
PGPASSWORD='mypassword' psql -h localhost -U myuser -d mydatabase

For pg_dump:

bash
PGPASSWORD='mypassword' pg_dump -h localhost -U myuser mydatabase

Warning: This method is less secure because environment variables may be visible in process lists. Use .pgpass for regular operations.

4Prompt for password interactively with psql

If you want to provide a password securely when running psql, use the -W flag to prompt:

bash
psql -h localhost -U myuser -d mydatabase -W

This will prompt you to enter the password interactively:

bash
Password for user myuser:

The password is not echoed to the terminal and is not stored in shell history.

5Check pg_hba.conf authentication method

Verify that pg_hba.conf allows password authentication for your connection:

bash
# Find pg_hba.conf location (usually in PostgreSQL data directory)
psql -U postgres -c "SHOW hba_file;"

# Check the file (usually /etc/postgresql/version/main/pg_hba.conf on Linux)
cat /etc/postgresql/14/main/pg_hba.conf

Ensure the authentication method supports password:

bash
# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     scram-sha-256
host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             ::1/128                 scram-sha-256

Valid password methods: scram-sha-256 (recommended), md5 (legacy), password (plaintext, use only with SSL)

After modifying pg_hba.conf:

bash
sudo systemctl restart postgresql
6For streaming replication: configure primary_conninfo

If you're setting up a PostgreSQL standby server and see this error during replication, configure primary_conninfo in recovery.conf or postgresql.conf:

bash
# Using password in connection string (less secure)
primary_conninfo = 'host=primary.example.com port=5432 user=replicator password=repPassword'

# Or use .pgpass (more secure)
primary_conninfo = 'host=primary.example.com port=5432 user=replicator'

Ensure the .pgpass file on the standby contains:

bash
primary.example.com:5432:replication:replicator:repPassword

With permissions:

bash
chmod 600 /var/lib/postgresql/.pgpass
chown postgres:postgres /var/lib/postgresql/.pgpass

Then restart the standby:

bash
sudo systemctl restart postgresql

Advanced notes

PostgreSQL supports multiple password authentication methods: SCRAM-SHA-256 (default in PostgreSQL 10+, most secure), MD5 (legacy, vulnerable), and plain password (only safe over SSL). The SCRAM-SHA-256 method uses a challenge-response mechanism that prevents password sniffing. If you're upgrading from older PostgreSQL versions using MD5, users must reset their passwords after changing pg_hba.conf to SCRAM-SHA-256. For automated backups and scripts, the .pgpass file is preferred over PGPASSWORD because it keeps passwords out of process lists and shell history. On Windows, the password file location is %APPDATA%\postgresql\pgpass.conf. For Docker containers connecting to external PostgreSQL, ensure the password is supplied either via .pgpass mount, environment variables within the container, or connection string parameters. Always verify the connection string format matches what your client library expects.

Frequently asked questions

What does "FATAL: no password supplied" mean?
PostgreSQL's libpq authentication layer is rejecting the connection attempt because no password was provided during the authentication handshake. This error typically appears when connecting to a PostgreSQL server that requires password-based authentication (SCRAM-SHA-256, MD5, or plain password methods) but the client hasn't supplied credentials. The error can occur with command-line tools like psql, pg_dump, or programmatic clients that don't handle password input correctly.
How do I fix "FATAL: no password supplied"?
This error occurs when a PostgreSQL client attempts to connect to a database but fails to provide authentication credentials. It happens when the user lacks a password, the .pgpass file is misconfigured, or environment variables aren't set properly.
What causes "FATAL: no password supplied"?
The user account exists in PostgreSQL but has no password set (created without one) The .pgpass file is missing, incorrectly formatted, or has wrong file permissions The PGPASSWORD environment variable is not set or is empty
Is the "FATAL: no password supplied" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading