1
Error: getaddrinfo ENOTFOUND whitedark

I am just connecting to mySQL. I installed mysql with npm install mysql command. This is my code.

var mysql = require('mysql');

var con = mysql.createConnection(
    {
        host: 'whitedark',
        user: 'whitedark',
        password: 'password'
    });

con.connect(function(err)
{
    if (err) throw err;
    console.log('Connected');
});

There is this error. { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'whitedark', fatal: true } Where is wrong? When I typed SELECT User, Host, plugin FROM mysql.user; I get this response. User = whitedark, Host = %, Plugin = caching_sha2_password, ........, User = root, Host = localhost, Plugin = mysql_native_password.

white dark
  • 65
  • 6
  • The error you're getting indicates that your NodeJS app can't resolve the hostname 'whitedark' to an IP address. If the MySQL server is on the same host as the script, you can use 'localhost', otherwise you need to put a valid IP address or DNS name in the `host` property. – ecnepsnai Aug 01 '21 at 17:14
  • When I use 'localhost' I got this error, any improvement? Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client – white dark Aug 01 '21 at 17:16
  • 1
    This answer details that error and what to do about it: https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server/56509065#56509065 – ecnepsnai Aug 01 '21 at 17:18
  • I got it. It connected. Thank you. – white dark Aug 01 '21 at 17:27
  • Does this answer your question? [MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client](https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server) – dusthaines Aug 02 '21 at 14:12

0 Answers0