I use node-postgres . The database cluster is created in WIN1251 encoding with the Russian_Russia.1251 locale.

var pg = require('pg'); var config = { host: '127.0.0.1', port: 5432, database: 'testbase', user: 'тест', password: '' }; var pool = new pg.Pool(config); pool.connect(function(err, client, done) { if(err) { return console.error(err); } console.log('Connected'); }); pool.on('error', function (err, client) { console.error(err.message, err.stack) }); 

If the username is in Latin, then the connection is normal. If the user is set in Cyrillic (as in the example), then an error is generated:

 { error: role "тест" does not exist at Connection.parseE (C:\Users\vbuser\node_modules\pg\lib\connection.js:554:11) at Connection.parseMessage (C:\Users\vbuser\node_modules\pg\lib\connection.js:381:17) at Socket.<anonymous> (C:\Users\vbuser\node_modules\pg\lib\connection.js:117:22) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:548:20) name: 'error', length: 93, severity: 'FATAL', code: '28000', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'miscinit.c', line: '433', routine: 'InitializeSessionUserId' } read ECONNRESET Error: read ECONNRESET at exports._errnoException (util.js:1026:11) at TCP.onread (net.js:569:26) 

The user 'test' in the database has been created and is connected via the console without any problems. PostgreSQL 9.3 version, node-postgres 6.1.2.

Tell me what the problem is.

  • one
    Check the encoding in the file and in the database. They must match. - Mikhail Vaysman
  • So it does not work either. Yes, and this is a strange option, in general, I may not know the encoding of the database. Yes, and I know that I have to edit the encoding in the file every time. - Alex
  • Can not overcome the problem. What other options? - Alex
  • one
    I have no answer. Perhaps the easiest solution would be to use only English characters for the name and password. - Mikhail Vaysman

0