SCRAM authentication failed
SCRAM-SHA-256 has been the default password_encryption since
PostgreSQL 14 and is the only authentication method on which
channel binding works. This page lists the SCRAM and channel-binding
failures on that path: what each user-visible error means and which
property or server change fixes it.
For the recommended-default posture (sslmode=verify-full,
channelBinding=require), see
Configure SSL/TLS (in Quick start)
.
Channel Binding is required, but SSL is not in use
Raised by ScramAuthenticator.getChannelBindingData when
channelBinding=require is combined with sslmode=disable (or any
configuration that never negotiates TLS). Channel binding ties the
SCRAM exchange to the TLS session; without TLS there is no channel
to bind to.
Resolution: pick one or the other.
- The intended posture is
sslmode=verify-full+channelBinding=require. This is the combination Configure SSL/TLS (in Quick start) recommends, and the only one that defends against an attacker who can terminate-and-replay the TLS handshake. - If TLS is genuinely impossible (a local Unix-domain socket bridge,
a closed dev loop) drop channel binding too:
channelBinding=preferordisable.
Channel Binding is required, but server did not offer an authentication method that supports channel binding
The server selected SASL/SCRAM, but the SASL mechanism list did not
include a -PLUS mechanism. pgJDBC raises this after it receives
AuthenticationSASL and finds no advertised mechanism whose name ends
with -PLUS.
The usual cause is an older server that supports SCRAM-SHA-256 but
not SCRAM-SHA-256-PLUS. Channel binding needs the
scram-sha-256-plus SASL mechanism, added in PostgreSQL 11. On
older servers, use channelBinding=prefer until you can upgrade.
Channel binding is required, but server requested 'md5' authentication
With channelBinding=require, pgJDBC rejects any non-SASL
authentication request before responding to it. The method name in
the message is whatever the server selected: md5, password,
gss, sspi, or a numeric code for an unsupported method.
Common causes:
pg_hba.confmatched a non-SCRAM rule. Reorder or replace the matching rule so this client useshostssl ... scram-sha-256.The user is stored with MD5 password encryption and
pg_hba.confmatchedmd5. Re-set the user password whilepassword_encryption = scram-sha-256is in effect inpostgresql.conf(the default since PostgreSQL 14):ALTER USER alice WITH PASSWORD 'plaintext'; -- gets stored as scram-sha-256\\passwordin psql works too. Confirm with:SELECT rolname, rolpassword FROM pg_authid WHERE rolname = 'alice';The value should start with
SCRAM-SHA-256$.
Channel binding is required, but server skipped authentication
The server accepted the connection without running SCRAM, usually
because the matching pg_hba.conf rule uses trust. Channel binding
can only be completed after a SCRAM-SHA-256-PLUS exchange, so pgJDBC
rejects this before the connection is handed back to the application.
Resolution: replace or reorder the matching trust rule so this
client uses hostssl ... scram-sha-256. If you intentionally rely on
trust for a closed local development loop, set
channelBinding=prefer or disable for that connection.
Channel Binding is required, but could not extract channel binding data from SSL session
The TLS handshake succeeded, but pgJDBC could not read or encode the
peer certificate from the JSSE session while building the
tls-server-end-point binding. In current code this message is raised
when SSLSession.getPeerCertificates() reports an unverified peer or
when the peer certificate cannot be encoded.
This normally points at the TLS socket/session implementation rather
than a pgJDBC property. Inspect a custom SSLSocketFactory first; the
stock org.postgresql.ssl.LibPQFactory is expected to expose the
server’s X.509 certificate.
There is no client-side property to bypass: channel binding cannot work without a server certificate.
Server requested N SCRAM PBKDF2 iterations, which exceeds the client-side limit of M
A safety cap. pgJDBC accepts at most scramMaxIterations PBKDF2
rounds from the server (default 100,000); higher counts are rejected
before the expensive PBKDF2 computation runs. Without the cap, a
malicious or compromised server could force the client to burn CPU
on an attacker-controlled iteration count.
Resolution depends on context:
- You trust the server and it legitimately uses a high count.
Raise
scramMaxIterations. Set to0to disable the check entirely (not recommended). - You do not trust the server. Do not raise the limit; the default is the protection, not the problem.
Authentication method is not allowed by requireAuth
You configured an explicit allow-list of authentication methods via
requireAuth
and the server offered something else. The property accepts a
comma-separated list of password, md5, gss, sspi, scram-sha-256, none, with a ! prefix for negative entries
(requireAuth=!password,!md5 forbids cleartext and MD5).
Resolution:
- Add the offered method to the list, if it was an oversight.
- Fix the server. If the server offers
md5and you wroterequireAuth=scram-sha-256, the password is stored under a weaker scheme. Migrate to SCRAM (see the first case above).
The error fires before authentication completes, so no credentials are ever sent under the unwanted method.
Authentication-related connection properties
| Name | Type | Default | Versions | Description |
|---|---|---|---|---|
authenticationPluginClassName | class | — |
| Name of class which implements AuthenticationPlugin |
channelBinding | enum | prefer |
| This option controls the client’s use of channel binding. |
password | string | — |
| Password to use when authenticating. |
requireAuth | string | — |
| Comma-separated list of acceptable authentication methods. Use ‘!’ prefix to reject methods (e.g., ‘!password’ to reject cleartext). Supported: password, md5, gss, sspi, scram-sha-256, none |
scramMaxIterations | int | 100000 |
| Maximum PBKDF2 iteration count accepted from the server during SCRAM authentication. A value of zero disables this check. |
user | string | — |
| Username to connect to the database as. |
Related
- Authentication
: the
conceptual companion to this page covers which methods the driver
supports, how the server-driven negotiation resolves, and the
levers (
requireAuth,channelBinding,scramMaxIterations,AuthenticationPlugin) that bound it. - Configure SSL/TLS (in Quick start)
:
the recommended-default combination of
sslmode=verify-full,sslrootcert, andchannelBinding=require. - SSL / TLS connection errors : failure modes on the TLS layer underneath SCRAM. Channel binding cannot succeed if the TLS handshake itself doesn’t.
- Compatibility : channel binding requires PostgreSQL 11+; SCRAM-SHA-256 is the default password encoding from PG 14.