I have a database hosted on cpanel and I am not able to connect to it. I am using ‘mysql’ package in node js. It throws the timeout error.
function create_connect(){
var connection = mysql.createConnection({
host : 'domain name',
user : 'user',
password : 'pass',
database : 'dbname'
});
connection.connect((err)=>{
if(err){console.log(err)}
else{console.log('connected!')}
});
return connection;
}
Also my node js code is on local machine and i am trying to connect db on cpanel host. I tried using ipaddress instead of domain name and adding my ip to remote sql in cpanel. Timeout error still persists.
Error: connect ETIMEDOUT
at Connection._handleConnectTimeout
2
Answers
If cpanel is installed by default, you can’t connect by specifying ip/hostname, because you need to add a host as a specific ip or% of users to connect correctly. You can view users through the default phpadmin of cpanel,
select host,user from mysql.user;
Same problem here, have you ever find a solution about this?