Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

JDBC cannot log in to PostgreSQL: authentication type 10

Errororg.postgresql.util.PSQLException: The authentication type 10 is not supported.

Short answer

Authentication type 10 is SCRAM-SHA-256, the password method PostgreSQL 14 and later use by default. A JDBC driver older than 42.2.0 does not speak it. Upgrade the postgresql driver in Gradle or Maven. Only if you cannot, store that role's password with md5 and match pg_hba.conf, knowing md5 is deprecated.

  • Applies to PostgreSQL 16, PostgreSQL 17, pgjdbc 42.7, Spring Boot 3, Gradle 9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the PostgreSQL driver version your build pulls in.

    ./gradlew dependencies --configuration runtimeClasspath | grep -i postgresql
  2. 2Match what you see, then jump to its fix

    1. 1The first step shows an org.postgresql:postgresql version below 42.2.0, often pinned by hand or by an old Spring Boot BOM.The JDBC driver is older than 42.2.0Fix
    2. 2The build shows a new driver, but the running app still fails, for example inside an app server or a fat jar from another project.A shaded or bundled old driver wins on the classpathFix
    3. 3You cannot upgrade the client in time.Last resort: the role needs an md5 passwordFix

What does the error look like?

  • org.postgresql.util.PSQLException: The authentication type 10 is not supported.

Cause 1 of 3

The JDBC driver is older than 42.2.0

1Check

SCRAM-SHA-256 support arrived in pgjdbc 42.2.0 and works from Java 8. An older driver does not recognise the server's request.

grep -rn "org.postgresql" build.gradle build.gradle.kts pom.xml 2>/dev/null

2Fix

Remove the old pin or set a current version. With Spring Boot, drop the version so the BOM manages it.

// build.gradle
runtimeOnly 'org.postgresql:postgresql'

3Verify

The listed version is 42.2.0 or higher, and the app connects.

./gradlew dependencies --configuration runtimeClasspath | grep -i postgresql

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

A shaded or bundled old driver wins on the classpath

1Check

Another jar can carry its own older copy of org.postgresql classes. Look at what the runtime really contains.

unzip -l build/libs/app.jar | grep -i postgresql
find / -name "postgresql*.jar" 2>/dev/null | head

2Fix

Remove the duplicate so one current driver is left, including copies in an application server's lib folder.

# delete or replace the old postgresql-*.jar in the server's lib directory

3Verify

Restart and connect.

./gradlew bootRun

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

Last resort: the role needs an md5 password

1Check

The hash type is fixed when the password is set, using password_encryption. md5 is deprecated and will be removed in a future PostgreSQL release.

SHOW password_encryption;
SELECT rolname, left(rolpassword, 10) FROM pg_authid WHERE rolname = 'app';

2Fix

Set the password for that one role again while password_encryption is md5, and let pg_hba.conf use md5 for it. Plan the driver upgrade, then go back to scram-sha-256.

SET password_encryption = 'md5';
ALTER ROLE app WITH PASSWORD 'new-password';
-- pg_hba.conf
-- host  app_db  app  10.0.0.0/8  md5

3Verify

Reload the config and connect with the old client.

SELECT pg_reload_conf();

Confirmed by postgresql.org

Did this fix it?

How do I stop it coming back?

  • Let the framework BOM manage the PostgreSQL driver version.
  • Before moving a server to scram-sha-256, check every client library supports it.
  • After changing password_encryption, set each password again: existing hashes are not converted.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.