Fix SCRAM Authentication Requires libpq Version 10 or Above

Version 10 or above is required for the libpq library used by the failing connection when PostgreSQL asks that client to authenticate with SCRAM. The database server is often already working correctly; the problem is usually an older client library loaded by an application, container, native extension, or language binding. Start by identifying the process that actually fails, then upgrade or rebuild that process with a compatible PostgreSQL client library.

Use this table to match the symptom to the component that needs attention.

Symptom Likely Cause Fix
Both psql and the application fail The installed client library is too old Upgrade the PostgreSQL client library and client tools
psql works, but Python, Node.js, or another app fails The application loads a different or bundled libpq Inspect and upgrade the library used by that runtime
A container fails but the host works The image contains an old library Rebuild and redeploy the image with a newer client library
A native Node.js driver fails A native addon was built against an old libpq Upgrade the library, then rebuild the addon
A Java application cannot use SCRAM The JDK or PostgreSQL JDBC driver is outdated Upgrade the Java runtime and JDBC driver

What the SCRAM libpq Error Means

SCRAM is PostgreSQL’s modern password-authentication protocol. PostgreSQL implements the SCRAM-SHA-256 mechanism, which performs a SASL authentication exchange between the client and server.

The error appears when all of these conditions are true:

  1. PostgreSQL selects SCRAM authentication for the connection.
  2. The client tries to authenticate through libpq.
  3. The loaded libpq library is too old to speak SCRAM.

The important version is the library loaded by the failing process, not necessarily the database server or a psql command in another shell.

This is why the message may appear in a Python stack trace as psycopg2.OperationalError, in a native Node.js module, during a framework migration, or only inside a Docker or Kubernetes workload.

A successful command-line connection does not prove that the application is fixed. Your interactive psql client may load a newer library than the application’s virtual environment, native extension, or container image.

How to Fix the SCRAM libpq Error

The error is resolved by identifying the runtime that connects, checking its libpq version, and upgrading or rebuilding that client.

Step 1: Identify the Exact Process That Fails

  1. Read the first application-specific line in the stack trace. Look for the executable, service, worker, container, migration command, or language package that opened the database connection.
  2. Run the failing operation in the same environment where it normally runs: the same container, virtual environment, service account, or CI job.
  3. Do not begin by upgrading the database server. The error message identifies a client-side compatibility problem.

For example, a Django application may fail while running migrations even though a shell session on the same host can connect with psql. In that case, the Python runtime and its PostgreSQL adapter are the components to inspect.

Step 2: Check the Client Library Available to That Runtime

Start with the command-line tools, but treat their output as a clue rather than final proof.

pg_config --version
psql --version

On Linux, inspect which shared library the psql executable loads:

ldd "$(command -v psql)" | grep libpq

If the application uses Python with psycopg2, ask that exact interpreter which libpq version it sees:

python -c "import psycopg2; print(psycopg2.__libpq_version__)"

For Psycopg 3, run this from the same virtual environment or container that runs the application:

python -c "import psycopg; print(psycopg.pq.version())"

These checks matter because Python packages can be installed in several ways:

  • A source-built adapter commonly links to the system libpq.
  • A prebuilt binary package can include its own copy of libpq.
  • A container image can have a different library than the host operating system.
  • A process started by systemd, Kubernetes, or a CI runner can use a different environment than your login shell.

If pg_config reports a current release but the Python check reports an older one, trust the Python runtime for this problem.

Step 3: Upgrade or Rebuild the Client That Actually Connects

Install or provide libpq version 10 or above in the environment that produces the error. The safest method depends on how that environment is built.

  1. Operating-system application: Upgrade the PostgreSQL client library through the operating system’s supported package source. If the operating system only supplies an older library, upgrade the base operating system or use a supported PostgreSQL client repository for that platform.
  2. Python application: Upgrade the PostgreSQL adapter package or rebuild it after the newer client development library is installed. If the adapter uses a bundled binary library, upgrading only the host package may not change what Python loads.
  3. Native Node.js application: Upgrade the system client library, then reinstall or rebuild the native addon.
  4. Docker or Kubernetes workload: Update the Dockerfile or base image, rebuild the image, push it to the registry, and recreate the workload. Updating a package on the host does not alter a library already baked into a running image.
  5. Compiled application: Rebuild and redeploy the application against the newer PostgreSQL client library. Do not manually replace random shared-library files or set a global loader path as a shortcut; that can create ABI and security problems for unrelated applications.

After the upgrade, remove old copies of the application artifact or image that could still be deployed. A new library on disk does not help if the process continues loading an older bundled copy.

Step 4: Restart the Failing Process and Test the Real Workload

Restart or recreate the service so it loads the updated library. A running process does not automatically switch to a newly installed shared library.

Then test with the same connection path and credentials used by the application. If you have a database URL stored as an environment variable, a simple command-line connectivity test is:

psql "$DATABASE_URL" -c 'select 1;'

That verifies the command-line client only. Finish by running the actual task that failed: the application startup, background worker, deployment migration, scheduled job, or native-driver connection.

If the original error occurred during a migration, rerun that migration rather than stopping after a generic connectivity test.

Runtime-Specific Cases That Commonly Cause the Error

Python, containers, Pulpcore migrations, and Java deployments can use different client dependencies than local tools or developer workstations.

Python and Psycopg

Python errors often name psycopg2, Django, SQLAlchemy, or another framework, but the root issue is still the PostgreSQL client library beneath the adapter.

A virtual environment isolates Python packages, not necessarily native shared libraries. Check the Python interpreter inside that environment, then determine whether the installed adapter is linked to the system library or ships with its own copy.

If a local terminal works but a Gunicorn, uWSGI, Celery, or systemd service fails, inspect the service’s virtual environment and restart the service after replacing the dependency.

Containers and Kubernetes

Containers make this issue easy to misdiagnose because host tools are irrelevant to the image. A host may have a current PostgreSQL client while an older image layer still contains a pre-SCRAM client library.

Rebuild the application image after updating its PostgreSQL client dependency. Then deploy the new image digest or tag and confirm that old pods, jobs, and migration containers have been replaced.

For Kubernetes Jobs and Helm hooks, check the image used by the migration job separately from the long-running application deployment. They may not use the same image.

Red Hat Satellite and Pulpcore Migrations

On Red Hat Satellite 6.10, this error can occur in the psycopg2 process that runs pulpcore-manager migrate --noinput. Checking an unrelated interactive psql client is not enough; inspect the libpq available to the Python environment that starts the Pulpcore migration.

After correcting that runtime, rerun the failed migration command:

pulpcore-manager migrate --noinput

If the command still fails, verify that the process is using the updated Python environment rather than a second system-installed copy of the application.

Java and PostgreSQL JDBC

A normal PostgreSQL JDBC connection does not use libpq; it uses the Java PostgreSQL driver directly. For SCRAM support, the PostgreSQL JDBC driver requires JDK 8 or later and pgjdbc 42.2.0 or later, using the regular driver artifact rather than a .jre build.

Check the runtime JDK used by the deployed service, not only the JDK installed on a developer workstation. Also inspect the final application classpath or dependency lockfile, because an older transitive JDBC driver can override the version you expected to deploy.

Why an MD5 Authentication Rule Can Still Result in SCRAM

A PostgreSQL pg_hba.conf entry that says md5 does not guarantee that the connection will use MD5.

PostgreSQL stores password verifiers for roles. A role that requires SCRAM can expose outdated clients.

That explains a common pattern:

  • An old application works with an older database role.
  • A password is reset or a new role is created.
  • The new role receives a SCRAM verifier.
  • The old client can no longer authenticate.

Changing only the HBA rule does not convert a stored SCRAM verifier into an MD5 verifier. The long-term fix remains upgrading the client.

Temporary MD5 Fallback for a Legacy Client

Use an MD5 fallback only when your server version and security policy still permit MD5 authentication. MD5 password verifiers are weaker than SCRAM, so keep the fallback narrow, temporary, and limited to a dedicated non-admin application role.

Connect as an administrator who is allowed to change the legacy role, then set password_encryption = md5 for that session:

SET password_encryption = 'md5';

Reset the password for the role used only by the legacy application. Use the role password reset command: \password legacy_app

\password legacy_app

Ensure the relevant pg_hba.conf rule permits MD5 authentication for that role and connection path, reload PostgreSQL configuration through your normal deployment process, then restart and test the legacy application.

When the client has been upgraded, convert the role back to SCRAM by setting the session password encryption method and resetting the role password again:

SET password_encryption = 'scram-sha-256';
\password legacy_app

Do not use this fallback for a shared administrator account.

Confirm the Fix and Prevent It From Returning

A successful repair has three parts:

  • The exact failing runtime loads a SCRAM-capable client library.
  • The service, worker, migration job, or container has been restarted or recreated.
  • The original database action completes with the account that previously failed.

For prevention, add a database connection test to the same build or deployment environment that runs the application. Use a test role with a SCRAM password verifier so the check exercises the authentication method that matters.

Also pin and review these dependencies together:

  • The base container image or operating system version
  • The PostgreSQL client package
  • Native language adapters and compiled extensions
  • Python wheel type or Node.js native addon build
  • The final Java runtime and JDBC driver version

A version check performed only on a developer laptop is not a reliable deployment check. The useful check runs inside the production-like container, virtual environment, or service runtime.

Frequently Asked Questions

Do I Need to Upgrade the PostgreSQL Server?

Usually, no. This error means the client that is connecting cannot perform the authentication exchange selected by the server. Upgrade the client library, native driver, or language runtime used by the failing process unless the server itself is also outdated for other reasons.

Why Does psql Work but My Application Still Fails?

Your application is probably loading a different PostgreSQL client library. This is common with Python binary packages, native Node.js addons, Docker images, separate virtual environments, and services started with a different environment from your interactive shell.

What Does a Java Application Need for SCRAM Authentication?

A Java PostgreSQL connection needs JDK 8 or later and pgjdbc 42.2.0 or later for SCRAM support. Standard JDBC uses the PostgreSQL JDBC driver directly, so an error mentioning libpq usually points to a separate native component rather than the JDBC driver itself.

Can I Keep Using MD5 Instead of Upgrading the Client?

You can temporarily reset a dedicated legacy role after setting password_encryption = md5, provided your PostgreSQL version and security policy still support MD5 authentication. This should be a short-term bridge because MD5 password verifiers provide weaker protection than SCRAM.

Why Did the Error Start After Creating a New User or Resetting a Password?

The new or reset password may have been stored as a SCRAM verifier while the old account still used an MD5 verifier. PostgreSQL can choose SCRAM for the new role, revealing that the application’s client library is too old even though it previously connected successfully.