tomyeh/postgresql

Unsupported or unknown authentication type: Unknown, only MD5 authentication is supported. (40004) #pg

d3roch4 opened this issue · 5 comments

I have a error:

dart run bin/server.dart 
Unhandled exception:
Unsupported or unknown authentication type: Unknown, only MD5 authentication is supported. (40004) #pg
#0      ConnectionImpl._readAuthenticationRequest (package:postgresql2/src/postgresql_impl/connection.dart:220:7)
#1      ConnectionImpl._readMessage (package:postgresql2/src/postgresql_impl/connection.dart:399:35)
#2      ConnectionImpl._readData (package:postgresql2/src/postgresql_impl/connection.dart:360:9)
#3      _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#5      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#7      _StreamController._add (dart:async/stream_controller.dart:648:7)
#8      _StreamController.add (dart:async/stream_controller.dart:596:5)
#9      _Socket._onData (dart:io-patch/socket_patch.dart:2324:41)
#10     _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
#11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#12     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#13     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#14     _StreamController._add (dart:async/stream_controller.dart:648:7)
#15     _StreamController.add (dart:async/stream_controller.dart:596:5)
#16     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1849:33)
#17     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#18     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#20     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
#21     _RawReceivePortImpl._handleMessage `(dart:isolate-patch/isolate_patch.dart:193:5)

My code is:

  const defaultUri = 'postgres://postgres:postgres@127.0.0.1:5432/test_database';
  const uri = String.fromEnvironment("SPUN_BOOK_DB", defaultValue: defaultUri);
  var conn = await connect(uri);

I have the same issue when running the examples.

details:
machine: Ubuntu 23.04
dart version: Dart SDK version: 3.0.0 (stable) (None) on "linux_x64"

Same issue over here!
Using postgresql 13

I have this issue too, after upgrade postgres 13 to postgres 15.

I resolved this.

first: must change password encryption in [/etc/postgresql/--version--/main/postgresql.conf]

  • sudo nano /etc/postgresql/15/main/postgresql.conf

change [#password_encryption = scram-sha-256] to [password_encryption = md5]
save and close

second: must change password method in [/etc/postgresql/--version--/main/pg_hba.conf]

  • sudo nano /etc/postgresql/15/main/pg_hba.conf

change any scram-sha-256 to md5
save and close

restart postgres:
- sudo service postgresql reload
- sudo service postgresql restar

note: this opration not work for old user. and you must reset you password.

you can see result by (select * FROM pg_authid WHERE rolcanlogin;) and you must see md5... in rolpassword column.

tomyeh commented

Fixed in a19b1a1
Thank @jimmyshiau for the fix.