How to migrate PostgreSQL passwords from MD5 to SCRAM-SHA-256 before MD5 support goes
If your self-hosted PostgreSQL cluster has roles whose passwords may still be stored as MD5 hashes, and nobody has set a removal date, this section is about turning that uncertainty into a planned conversion. PostgreSQL has deprecated MD5 password support in favor of SCRAM, and the documentation states that MD5 will be removed in a future release. No removal release is named in the sources we rely on, so treat the timing as unknown and plan as if it could come sooner than you expect. The work is well bounded: change the hashing setting, reset each role password so a SCRAM hash is stored, move the md5 lines in pg_hba.conf to scram-sha-256, verify clients, then confirm nothing still authenticates with MD5.
Start by inventorying what exists. Query pg_authid for roles whose rolpassword begins with md5, and review every md5 entry in pg_hba.conf across all instances, including replicas and standby clusters. Note that PostgreSQL chooses SCRAM automatically when md5 is listed but the stored password is SCRAM-encrypted, so a mismatched entry can hide the problem. Set password_encryption to scram-sha-256 before resetting passwords, otherwise the reset may store a new MD5 hash. Then change the method in pg_hba.conf, reload the configuration, and test each application, batch job and monitoring agent. Client driver versions matter here, so confirm with each driver vendor that it supports SCRAM before you switch its method.
Plan this alongside PostgreSQL 14 reaching end of life on November 12, 2026, because the cutover window for an upgrade is often the same window you need for password changes. Ask your team to confirm which MD5 consumers are owned by people outside the database team, since those are the usual reasons the final MD5 entry stays in place. Keep a record of which roles were reset, when, and which clients were verified, so an auditor or incident responder can see the conversion was controlled. Your next step is the PostgreSQL password authentication documentation, which sets out the exact behavior you will be testing against.
What changes in PostgreSQL when MD5 passwords are retired
This table lists each change that affects an MD5 to SCRAM migration, with its impact on roles, pg_hba.conf, clients and monitoring, and the action to take. Read it as a checklist: the deprecation and the removal are the reasons to act, while the warnings and fallback rules explain what you will see during the transition.
| Change | Impact on roles, pg_hba.conf, clients and monitoring | Action for the team |
|---|---|---|
| MD5 deprecated in PostgreSQL 18 | Roles with MD5-stored hashes still work, but the release announcement marks MD5 as deprecated in favor of SCRAM. Plan the migration now rather than at removal. | Inventory every role's password hash type and set a migration deadline before the removal release is named. |
| Future release removes MD5 support | The PostgreSQL password authentication docs say MD5 will be removed in a future release. No removal version is supplied here, so MD5 logins can stop working without a date you control. | Confirm the removal release with the PostgreSQL project notes for each target version and finish resets before upgrading past it. |
| PostgreSQL 19 warning after successful MD5 authentication | Each successful MD5 login writes a warning to the server log. Log-scanning or alerting rules may start firing during the rollout. | Use md5_password_warnings in a test environment to confirm the log format, then decide whether to keep warnings on in production. |
| md5 line in pg_hba.conf with a SCRAM-stored password | If the stored password is SCRAM-encrypted, the server chooses SCRAM even when the pg_hba.conf line says md5. Old config lines can look unsafe but authenticate with SCRAM. | Audit pg_hba.conf for md5 entries and change them to scram-sha-256 so the file states what actually happens. |
| Roles still holding MD5 hashes | Any role whose password was set before password_encryption was changed keeps an MD5 hash and will fail once MD5 support is removed. | Reset each affected role password after setting password_encryption to scram-sha-256, then confirm the stored hash type. |
| Client and driver support | Older client libraries may lack SCRAM support or be configured for MD5 only. Failures appear as authentication errors in applications, not in the database. | List every client, driver and version in use, test SCRAM login against each, and upgrade drivers that cannot negotiate SCRAM. |
| Monitoring and alerting | Connection failures and authentication log lines change during the migration. Dashboards built on old error text may miss new failures. | Add alerts for authentication failures and MD5 warnings, and record the time of each cutover for later review. |
How PostgreSQL chooses the password method for each login
The login starts when a client connects and the server scans pg_hba.conf for the first matching line. If that line names md5, PostgreSQL still looks at the hash stored for the role: a SCRAM-stored password authenticates with SCRAM, while a stored MD5 hash keeps the login on MD5. Each MD5 login is the signal to check in logs before you remove MD5 support.
Login path showing when an md5 line still uses MD5 and where to check logs.
What to inventory before changing any password
Four preparation items can run in parallel before any role is touched. Together they show which accounts still hold MD5 hashes, which authentication rules depend on them, which clients must speak SCRAM-SHA-256, and where a safe rehearsal can happen. Skipping any one of them tends to turn a password change into an outage.
Role and hash inventory
List every role in the cluster and whether its stored password is MD5 or SCRAM-SHA-256. You can read the hash method from the catalog without ever displaying hash values, so keep the output limited to role names and method labels. Roles without a password, and roles that only authenticate through certificates, GSSAPI or LDAP, are not affected by the hash change but should be recorded so nobody assumes they are. Expect the list to include service accounts that nobody has logged into for years.
Password authentication docspg_hba.conf inventory
Record every line in pg_hba.conf that uses the md5 method, along with the databases, users and source addresses each line covers. A catch-all line such as host all all 0.0.0.0/0 md5 covers far more than its comment suggests, so expand it into the real role and network groups it serves. Also note any lines using scram-sha-256 and any include files, because a rule hidden in an included file is easy to miss during review.
Client and driver inventory
List every application, driver, connection pooler and proxy that opens connections to the cluster, with its version and its SCRAM-SHA-256 support. Older JDBC, ODBC, Python or Go drivers may connect with MD5 only, so confirm support in each driver's own documentation rather than assuming it. Include analytics tools, backup agents and monitoring exporters, since these often run under shared accounts that no application owner tracks.
Pooler and proxy authentication path
Connection poolers such as PgBouncer sit between clients and the server and often authenticate twice: clients to the pooler, then the pooler to PostgreSQL. Check how the pooler stores or fetches the credentials it uses to log in upstream, and whether it supports SCRAM passthrough for the version you run. A pooler that still uses an MD5 upstream login will keep MD5 active even after every application has moved. Confirm this against the pooler's current documentation and test it directly.
PgBouncer siteVerified backup and staging cluster
Before changing any role, confirm you hold a backup that has been restored successfully, and build a staging cluster with production-like roles, hash methods and pg_hba.conf rules. Copy role definitions and rules, not production data, where privacy rules require it. Staging is where you test each client and pooler against the new hash method and where you rehearse a rollback. Record who owns the backup restore test and how long a restore takes, so the change window reflects real timings.
The migration sequence with checks and rollback points
This sequence moves every role from MD5 to SCRAM-SHA-256 in staging first, then in production, and removes MD5 only after logs and the catalog show nothing still depends on it. Each step ends with a check and a point where you can stop or reverse the change.
Set password_encryption in staging
The database administrator sets password_encryption to scram-sha-256 on the staging cluster with ALTER SYSTEM, reloads the configuration, and then runs SHOW password_encryption from a new session to confirm the value took effect. This setting only affects passwords written after the change, so existing hashes stay MD5 until each role is reset. Rollback point: setting it back to md5 is a configuration change with no data impact, and no role has been touched yet.
Reset role passwords in staging
Converting a stored MD5 hash to SCRAM requires the plaintext password, which the server does not keep. Each role owner or an administrator therefore sets a new password with ALTER ROLE under a documented change record, and that person must hold the new secret through your normal vault process. Check pg_authid, or the rolpassword column in pg_authid for each role, and confirm the stored value begins with the SCRAM-SHA-256 prefix rather than md5. Rollback point: staging can be restored from its own backup if a reset breaks a test.
Test every client and pooler against staging
Run each application, batch job, migration tool, monitoring agent and connection pooler against the staging cluster using its own driver and connection string. Confirm the login succeeds and that the server reports SCRAM as the method used, and check driver versions that predate SCRAM support on your list. Pooler credentials, such as those used by PgBouncer, need their own test because they hold a copy of the authentication data. Rollback point: any client that fails is fixed or upgraded before production, and nothing has changed in production yet.
Switch pg_hba.conf to scram-sha-256 in staging
In the staging pg_hba.conf, the administrator changes the METHOD column from md5 to scram-sha-256 for the rules that handle password logins, then reloads the server. Authentication still succeeds for roles that have SCRAM hashes, and failed logins for roles still holding MD5 hashes show the fault in the server log, which tells you which roles were missed. Rollback point: keep the previous pg_hba.conf under version control so the change reverts with one reload. PostgreSQL chooses SCRAM automatically when a stored password is SCRAM-encrypted, but explicit methods make the mismatch visible.
Repeat the resets in production during a window
Run the same role resets in production inside an approved maintenance window, with a written rollback plan covering the pg_hba.conf file, the password_encryption setting and a verified backup taken just before the change. Each affected application team confirms its connections after its role is reset, and the administrator records the time and the operator for every change. Rollback point: restoring the saved pg_hba.conf and reloading returns logins to their previous state for roles not yet changed, and any role reset can be undone only by setting its old credential again, so the change record should keep that path clear.
Check logs and catalog for remaining MD5 use
Query pg_authid for any rolpassword value that still starts with md5, and review server logs for authentication failures and, where your version supports it, deprecation warnings after successful MD5 logins. PostgreSQL 19 issues a warning after successful MD5 password authentication, which md5_password_warnings can disable, so keep warnings enabled during this review. Include connections from pooler and monitoring accounts in the review. Done means the catalog query returns no MD5 hashes and the logs show no MD5 logins for a period you have agreed with the application owners. Ask your database team to confirm the period and the log retention you need.
Remove md5 lines from pg_hba.conf
Once the checks show no MD5 hashes and no MD5 logins, the administrator deletes the remaining md5 entries from pg_hba.conf, reloads, and confirms the server still accepts every expected connection from the test list. Keep the prior file in version control for the change record. Rollback point: until the old file is discarded, you can restore md5 entries, but restoring them does not help a role whose hash has already been converted, so that role needs its password reset again. Record the final state and close the change with the monitoring and pooler owners.
What makes the MD5 to SCRAM migration longer or shorter
This table lists the factors that raise or lower the effort of moving role passwords from MD5 to SCRAM-SHA-256. Read each row as a question to answer about your own environment before requesting a quote, since most of the work comes from finding and coordinating the clients that still authenticate with MD5.
| Driver | Effect on effort | What to ask for in a quote |
|---|---|---|
| Number of roles and whether any are shared | Raises effort. Each role needs a reset, and shared or service roles need coordinated cutover with every user of them. | A role inventory showing each role, its owners, and whether it is shared or used by batch jobs. |
| Batch jobs and scheduled tasks using stored credentials | Raises effort. Jobs often hold passwords in config files or scripts that must be found and updated in the same window. | A list of jobs, schedulers and secret stores that read database passwords, with the change window each one needs. |
| Applications and drivers that need checking or upgrading | Raises effort. Each client library must be confirmed to support SCRAM-SHA-256, and older drivers may need upgrading and retesting. | A client inventory with driver versions and a per-client compatibility check plan. |
| Number of pg_hba.conf lines and environments | Raises effort. Each md5 entry must change to scram-sha-256 in every environment, and drift between environments adds review time. | The count of md5 entries per environment and the process for reviewing changes across development, test and production. |
| PgBouncer or another pooler in front of the database | Raises effort. Poolers may store or forward password hashes, so their auth configuration and hash handling must be checked and often reloaded. | Confirmation of how the pooler authenticates clients and to the server, and the reload steps for each pooler instance. |
| Number of replicas and standbys that must match | Raises effort. Standbys share the primary's role catalog, but authentication settings in each server's configuration must be verified and reloaded. | A list of primaries, standbys and their pg_hba.conf files, plus the verification steps for each one. |
| Number of teams that own passwords | Raises effort. Each owner must agree on timing, confirm their services, and supply new credentials to their own secret stores. | A RACI or owner list for each role and the approval path for each password change. |
| Conversion tied to a major upgrade | Can lower or raise effort. Combining the change with an upgrade reduces separate windows but adds risk if both fail at once. | Whether the quote covers the MD5 change alone, a combined upgrade, or both, and how rollback is handled for each. |
How to confirm nothing still authenticates with MD5
Confirming that nothing still authenticates with MD5 takes three checks that cover different places a weak hash can hide. First, query the catalog for roles whose stored password is still an MD5 hash. In pg_authid, MD5 hashes begin with the prefix md5, while SCRAM verifiers begin with SCRAM-SHA-256$. Any role returned by a query that filters on the md5 prefix still holds an MD5 verifier and needs a password reset before the change is complete. Roles without a password set will not appear, so review those separately against your inventory of service accounts.
Second, review pg_hba.conf for any remaining md5 lines, including entries that apply to replication, administrative and application databases. A rule that says md5 is not the same as a rule that says scram-sha-256. PostgreSQL chooses SCRAM automatically when the stored password is SCRAM-encrypted, so a remaining md5 line may still work after the password change, but the line should be changed anyway so that it states what you intend. Check the file on every node, including standbys and any proxy configuration in front of the database, because a file that differs between nodes will not show up in a single-node review.
Third, read the server logs for authentication events after the change. A successful MD5 authentication is the signal you need, so keep the warning that PostgreSQL 19 issues after successful MD5 password authentication turned on during verification. The md5_password_warnings setting can disable that warning, and silencing it would remove the evidence you are looking for. Confirm the log format, the warning text and the settings that control logging in the documentation for your version, since the wording and the default levels can differ. Save the query output, the pg_hba.conf review, the log excerpts and the dates they cover in your change record, so an auditor or reviewer can see what was checked and when.
Questions teams ask before migrating MD5 passwords to SCRAM-SHA-256
How much effort does migrating PostgreSQL MD5 passwords to SCRAM-SHA-256 take?
The effort is usually modest per role but grows with the number of roles and the number of applications that log in with them. The work has four parts: setting password_encryption to scram-sha-256, resetting each role password so it is stored as SCRAM, changing the md5 method to scram-sha-256 in pg_hba.conf, and confirming that every client connects successfully afterward. The largest share of effort is usually finding which clients still depend on MD5 and coordinating their owners, not running the SQL. Ask any partner to break the quote into inventory, role resets, configuration changes, client testing and cutover support, so you can see where the hours go.
Can our own team migrate MD5 passwords to SCRAM without a partner?
Yes, a team with database administration skills and access to the cluster can do this in-house. The steps are well documented in the PostgreSQL password authentication documentation, and the risk is manageable when the role count is small. Teams often bring in outside help when they have many roles across several clusters, when client owners are spread across business units, when they need a tested rollback, or when the same window also covers a major upgrade. Decide based on your inventory and the staff hours available, not on the technique alone.
How long does an MD5 to SCRAM migration take?
The duration depends mainly on how many roles and client applications exist and how many owners must test before a change window is approved. A cluster with a few roles and well-known clients can be planned and executed quickly, while a shared cluster with dozens of applications needs longer for inventory, testing and scheduling. No single duration applies across environments. Ask for a timeline that lists the inventory phase, the testing phase per client, and the change window dates, and confirm each one against your own change calendar.
What does the migration need from our team?
The work needs several specific inputs before it starts. Expect to provide:
- Read access to
pg_authidor the role catalog, and a list of roles that log in - The current
pg_hba.conffiles for every cluster in scope - Named owners for each client application, driver and connection pooler, with access to test them
- A change window that allows a rollback and a sign-off from the application owners
- Someone who can approve role password changes and store the new credentials in your secrets system
Does an md5 entry in pg_hba.conf switch to SCRAM when a password is reset?
No, changing the stored password does not change the authentication method on its own. The PostgreSQL password authentication documentation says that when md5 is set in pg_hba.conf but the stored password is SCRAM-encrypted, SCRAM is chosen automatically. This means a role reset to SCRAM will authenticate with SCRAM even under an md5 line. The md5 line should still be changed to scram-sha-256 so that no MD5 hash remains available to authenticate against. Check the rule order in pg_hba.conf, because an earlier line can match first and change the outcome.
What happens to older drivers and clients after the change?
Clients that support SCRAM-SHA-256 keep working after the change, while very old drivers that only know MD5 will fail to log in once their role no longer has an MD5 hash and the method is set to SCRAM. Confirm the driver version and library for each client, including connection poolers, ORMs, reporting tools and batch jobs that may bundle an older library. Test each one against a staging cluster with the same pg_hba.conf and a role already reset to SCRAM. If a client cannot be upgraded, plan a separate role or a delayed change for it, and record the decision with its owner.
Should we combine the MD5 to SCRAM change with a PostgreSQL major upgrade?
You can combine them, but the decision should rest on your change control and rollback plans. Combining reduces the number of client test cycles, because drivers are tested once. It also increases the number of moving parts in one window, so a password problem and an upgrade problem can appear together and be harder to diagnose. Teams on PostgreSQL 14 with a November 12, 2026 end of life often schedule both, while keeping the password change as a separately verified step with its own rollback. Ask any partner to show how each step can be reversed independently before agreeing to one window.
How DeployOpen scopes and delivers the MD5 to SCRAM migration
DeployOpen approaches the move from MD5 to SCRAM-SHA-256 as a fixed-scope piece of work inside your own PostgreSQL environment. We start by inventorying which roles, pg_hba.conf rules and client applications still depend on MD5, then agree the deliverables in writing before any change is made.
How we scope
- We inventory every role whose stored password is MD5-hashed and every pg_hba.conf line that uses the md5 method.
- We list client applications, drivers and connection pools that must support SCRAM-SHA-256 before the cutover date.
- We agree the written scope, cutover window and rollback steps with your database, security and application owners before work starts.
How we build
- We set password_encryption to scram-sha-256 and test the change in a non-production cluster first.
- We reset role passwords in a controlled sequence, with each client change confirmed against a test login before the next step.
- We change pg_hba.conf methods to scram-sha-256 and check the server configuration reloads and authenticates as expected.
How we hand over
- We deliver the role inventory, configuration diffs and a runbook covering each password reset and pg_hba.conf change.
- We provide evidence that no connection in the logs still authenticates with MD5, with the queries and log checks used to confirm it.
- We document the driver versions tested and the open items your teams need to close, such as applications with hard-coded credentials.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, which you can use for follow-up after the migration.
- We can retest authentication settings after a PostgreSQL minor release or a major upgrade, such as the move to PostgreSQL 19 once it is released.
- Ask us to confirm the support terms, response expectations and retest scope in the written quote before the engagement starts.

