Monday, 12 June 2017

Unable to connect MySQL DB, getting ECONNREFUSED

I tried to connect the DB via MySQL Java Script as below:

 var mysql = require('mysql');  
 var con = mysql.createConnection({  
   host: "******",
   user: "******",
   password: "******"
 });  
 con.connect(function(err) {  
 if (err) throw err;  
   console.log("Connected!");
 });

And I'm using Node to execute, While I execute the above program getting the below error message:

if (err) throw err;
       ^
Error: connect ECONNREFUSED XX.XXX.XX.XXX:3306
  at Object.exports._errnoException (util.js:1018:11)
  at exports._exceptionWithHostPort (util.js:1041:20)
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

Also I have pinged my ip address (ping XX.XXX.XX.XXX) and can able to get the response. Can help me to connect the DB.



via KAK

No comments:

Post a Comment