I try to make a simple connection to an online mysql database on a node.js server. This is my code:
var mysql = require('mysql');
var con = mysql.createConnection({
host: 'example.org',
username: 'myusername',
password: 'mypassword'
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
Whenever I run this server I get the error: "connect ETIMEDOUT".
I am a 100% sure my credentials are correct and I also changed the privileges of the user in phpmyadmin (I gave this user all possible privileges).
I run the server locally, I am not sure if this has anything to do with it.
My questions are: - Why is it timing out? - And how can I connect to this database?
Error: connect ETIMEDOUTin the connect callback indicates that the connection to the mysql server could not be established. Are you sure that thehostyou entered points to an ip the mysql server is listening to and that mysql ist listening to the standard port?