error: password authentication failed for user "postgres"

236 Views Asked by At

How to fix this error nodemon app crashed?I'm using postgres sql as database and not mongodb. How can I fix this error?

error: password authentication failed for user "postgres" [nodemon] app crashed - waiting for file changes before starting...

                                                                                                 ^

error: password authentication failed for user "postgres"
    at Parser.parseErrorMessage (C:\Users\HP\Downloads\8.3+Travel+Tracker\8.3 Travel Tracker\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (C:\Users\HP\Downloads\8.3+Travel+Tracker\8.3 Travel Tracker\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (C:\Users\HP\Downloads\8.3+Travel+Tracker\8.3 Travel Tracker\node_modules\pg-protocol\dist\parser.js:39:38)
    at Socket.<anonymous> (C:\Users\HP\Downloads\8.3+Travel+Tracker\8.3 Travel Tracker\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 104,
  severity: 'FATAL',
  code: '28P01',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'auth.c',
  line: '326',
  routine: 'auth_failed'
}

Node.js v20.11.0
[nodemon] app crashed - waiting for file changes before starting...
1

There are 1 best solutions below

1
emreyanik On

If you have not defined a password for the postgres user, you must define a password. Just remember that the postgres user is a user with superuser privilege. Therefore, it is not recommended to use it as an application user. You can define a password for the user or change the existing password as follows. First, log into the database server.

sudo su - postgres
psql 

Change the user's password.

alter user postgres with password 'password'