1

I am using npgsql for postgresql13, but when trying to connect I get the following error:

only authentication clear text password and authentication md5 password supported for now. received 10

My connection line is: NpgsqlConnection conn = new NpgsqlConnection ("Server = xxxx; Port = xxxx; User Id = xxxx; Password = xxx; Database = database;")

Everything worked fine in postgresql 9.6 but it was migrated to version 13 and it generated this problem

  • So it seems that [password-encryption](https://www.postgresql.org/docs/13/runtime-config-connection.html#GUC-PASSWORD-ENCRYPTION) was set to md5 when the password was stored. – Klaus Gütter Nov 22 '20 at 14:20

5 Answers5

6

I have had the same error with a Npgsql 4.5 installed and postgresql-15. The password_encryption line was already commented in the postgresql.conf file.

What solved the problem to me was to modify the pg_hba.conf and change the method from "scram-sha-256" to "password" for all the entries in the file, for example

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
# IPv6 local connections:
host    all             all             ::1/128                 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     password
host    replication     all             127.0.0.1/32            password
host    replication     all             ::1/128                 password
Sergio Prats
  • 1,043
  • 1
  • 14
  • 19
3

You need to upgrade Npgsql 4.0 or better, which supports the scram-sha-256 authentication method available since PostgreSQL v10.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
2

Thanks for your help, libraries do need to be updated.

In case of not being able to change, as is my case, the following should be done:

In the postgresql.conf file comment out the line, #password_encryption, you may need to re-generate the password.

1

The database server may have been upgraded, but the client library which C# is using to connect to the server has not been. The old client does not understand the new authentication method. Try updating the npgsql library.

jjanes
  • 37,812
  • 5
  • 27
  • 34
0

Maybe you write incorrect port in connection string. I had the same problem, and it resolved after I changed port number in conn string