I'm trying to connect to a MYSQL database using the npm MYSQL library(https://www.npmjs.com/package/mysql), but I'm getting a error that the server can't be connected to. When I go into the server, I can see the DB, and I validated my credentials and they're valid. My app lives on our seperate server with IP address ending in 123.75, while the DB is on 123.74. I'm using a route I setup on Express to call the DB. I've listed the Express & NPM MYSQL code below (credentials redacted), along with the error I'm receiving.
NPM MYSQL:
const config = sql.createConnection( {
host: '123.74:3306',
user: 'root',
pass: '****',
database: '****'
});
Express Route:
app.use('/t',function(req,res){
config.connect(function(err){
if (err){
res.send(err);
return;
}
res.send('connected');
});
config.end();
});
Error:
{"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo","hostname":"123.74:3306","host":"123.74:3306","port":3306,"fatal":true}
Update:
I found the issue in the library, and posted a solution.