How Can I Solve Postgresql Scram Authentifcation Problem?
I Am Getting an Error After Moving the Project to Production. the Error Is as Follows While Running with Production Server Pg_Connect(): Unable to Connect to...
I am getting an error after moving the project to production. The error is as follows while running with production server
pg_connect(): Unable to connect to PostgreSQL server: SCRAM authentication requires libpq version 10 or above.
Here is my postgreSQL version:
Development Version :
PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
Production Version :
PostgreSQL 11.5 (EnterpriseDB Advanced Server 11.5.12) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
7 Answers
For those on M1-Based macs who are currently seeing this issue in docker - there appears to a bug upstream in libpg that's building against the wrong library version on ARM.
Until it's fixed, a workaround is to (at a performance hit) is to just run it via rosetta.
export DOCKER_DEFAULT_PLATFORM=linux/amd64, and re-build your images.
You'll get the latest version of libpq, and things should Just Work.
Ref:
Your application uses an API that is linked with the PostgreSQL client C library libpq.
The version of that library must be 9.6 or older, and SCRAM authentication was introduced in v10.
Upgrade libpq on the application end and try again.
If you don't need scram-sha-256 authentication, you can revert to md5:
- set
password_encryption = md5inpostgresql.conf - change the authentication method to
md5inpg_hba_conf - reload PostgreSQL
- change the password of the user to get an MD5 encrypted password
I used to get an error SCRAM authentication requires libpq version 10 or above when running php artisan migrate in laravel 8. Then I fixed it as follows: Change authentication from scram-sha-256 to md5, then reset your password and restart the postgresql-x64-13 service and here are step by step:
- Step 1: Find file
postgresql.confinC:\Program Files\PostgreSQL\13\datathen setpassword_encryption = md5 - Step 2: Find file
pg_hba.confinC:\Program Files\PostgreSQL\13\datathen change allMETHODtomd5 - Step 3: Open
command line (cmd,cmder,git bash...)and runpsql -U postgresthen enter your password when installed postgres sql - Step 4: Then change your password by run
ALTER USER postgres WITH PASSWORD 'new-password'in command line - Final: Restart service
postgresql-x64-13in yourService.
I ran into this while running a python:3.9 docker image where I had installed psycopg2-binary==2.9.3. Installing psycopg2==2.9.3 instead resolved it for me.
Encountered the same issue and applied @Laurenz Albe's fix but I would get an authentication error on my user for the database, because of encryption strategy change.
So instead of replacing scram-sha-256 with md5, replace it with trust in pg_hba.conf
If you want to keep the scram-sha-256 for security. You need to update your client postgreSQL libraries, due to php-pgsql default version does not support it.
CentOS/Rhel/Rocky
yum install
yum instal postgresql13
This will update the server/client libpq in order to keep using scram-sha-256
RUN apt-get -y update \
&& apt-get install -y build-essential gettext libpq-dev\
&& apt-get install -y wkhtmltopdf\
&& apt-get install -y gdal-bin\
&& apt-get install -y libgdal-dev\
&& apt-get install -y --no-install-recommends software-properties-common\
&& apt-add-repository contrib\
&& apt-get update
Try this.