TechSelfLearner
TechSelfLearner

Reputation: 397

Authentication error in connecting with postgres database

so I am working on the backend of my web app. I keep getting this error: password authentication failed for user "postgre"

const express = require("express")
const router = express.Router()
const Pool = require('pg').Pool
const pool = new Pool({
    user: 'postgre',
    host: 'localhost',
    database: 'p2p',
    password: 'hello',
    port: 5432,
  })

router.get('/',(req,res)=>{
    res.render('physician/login')
})

//table: doc_reg, 
router.post('/loggedin',(req,res)=>{
    const {user_name,pw_1}=req.body
    pool.query('INSERT INTO doc_reg (username,pw) VALUES ($1,$2)',[user_name,pw_1],(err, results)=>{
        if (err){
            console.log(err)
        }
        res.render('physician/loggedin',{username:user_name})
    })
})

module.exports=router

Anything went wrong here?

Upvotes: 0

Views: 520

Answers (1)

amit gupta
amit gupta

Reputation: 866

Generally, this error occurs when you are using the wrong password for the given user.

Upvotes: 1

Related Questions