Home > Net >  I am trying to connect my web page to my local server database but I am getting error ECONNREFUSED
I am trying to connect my web page to my local server database but I am getting error ECONNREFUSED

Time:02-18

 errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3000,
  fatal: true

I am using Mac OS and VS Code to connect to my local server. I have connected mysql workbench to VSCode as well and it is working fine. But when I try to connect it with my program it is not working. I changed the hostname from 'localhost' to '127.0.0.1' as well still no luck. Also, I changed my port from 3306 to 3000 as it was not connecting and I got the following error

code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlMessage: "Access denied for user 'usersql'@'localhost' (using password: YES)",
  sqlState: '28000',
  fatal: true

My code:

const { createPool } = require('mysql')

const pool = createPool({
    host: "127.0.0.1",
    user: "usersql",
    password: "password!23",
    database: "userdb",
    connectionLimit: 10,
    port: 3000
})

pool.query(`select * from userdb.New_Customer`, function(err, result, fields) {
    if (err) {
        return console.log(err);
    }
    return console.log(result);
})

CodePudding user response:

It's a login failure. The reason can be anything from active firewall, to wrong authentication mode to wrong user credentials. this might help you, MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

  • Related